From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2103.outbound.protection.outlook.com [40.107.236.103]) by sourceware.org (Postfix) with ESMTPS id CC5193858429 for ; Mon, 13 Sep 2021 02:19:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CC5193858429 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=cornell.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cornell.edu ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hiSnCF4Pd+bCwogwBROFols6BA0teH8tEHbhs1UIRDimQ8lDSXt6uaFNXl3y4z52Um+YAliOqluuYj+H/HZLg3/dOTpEsbc6E308nJQW4nQqGDsVtLCjf/r773MIPvlInEefPhEqfhTbT2EXGDnJeX6GLUg/AHJ2juY7B7niTTnhlBKg+cxk07RJ02VtD4jxitmXbXz+SdcLOSLAeVfrEcegBJRQOLRwTDmY3TVyqAlRcqiAuwKSk2AlTzdBXds3kkebV/HD18MpTc/FxtZinnB/XBHjfpZ7Iz6lUmw9cuzRw7NQroMmHzwTuiH/t3iCrffOIsZMG8gdSnqDJU2y1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=63aFwSREcqthhgbHq4KqK2a+iqf7EVj8d905+ExyQSc=; b=OiNLLPqp14S64ADxOiiaC0PXJL7eutlswJRhAjvqwSTiE3WkmZqnQ+YavJDiiLv3JLewOuWNaixvAmwXcXXgI8/z7x685xPvRkq0g99TY3msM4tmig6MvBbQIrRAYxOtsin80v8aQC5NgXOYLUdPx+5hr3Ji/8XfAt8YzkjbGTUR1uCziPWJ23Ih2g9oq44adXVRaNhbcXl/53+OiiW25JpAStyK+RXe3tQPYouPTmUkBZZEtuMi43NBegrV9P97qIKZ9EYrph/xFGDcZAJw6BWVQuP8HxBlHjTN/IKqKwN+7pZ2Q/9qrqF+clckVYClDMJiCxO5Poz38lrrJeU5JA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cornell.edu; dmarc=pass action=none header.from=cornell.edu; dkim=pass header.d=cornell.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cornell.edu; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=63aFwSREcqthhgbHq4KqK2a+iqf7EVj8d905+ExyQSc=; b=ffbnakgVvBCtMVPxcO5UxzhOwIeD2cmsje7RmZxprOxdscN33vfFVf+CxNRISXN9x77wgzsGyxHjWBBRG4mdRifHcfwnSLIVU/W8oNPPOBo7+qc56tijwNMpylZL3NiczDGZPx3Ii//Xj1CM18eovvQvaSVzQcXwb1Yx1QzjIus= Authentication-Results: cygwin.com; dkim=none (message not signed) header.d=none;cygwin.com; dmarc=none action=none header.from=cornell.edu; Received: from BN7PR04MB4388.namprd04.prod.outlook.com (2603:10b6:406:f8::19) by BN7PR04MB4052.namprd04.prod.outlook.com (2603:10b6:406:c0::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Mon, 13 Sep 2021 02:19:39 +0000 Received: from BN7PR04MB4388.namprd04.prod.outlook.com ([fe80::5113:e84a:b38a:7a66]) by BN7PR04MB4388.namprd04.prod.outlook.com ([fe80::5113:e84a:b38a:7a66%6]) with mapi id 15.20.4500.018; Mon, 13 Sep 2021 02:19:39 +0000 Subject: Re: cygrunsrv + sshd + rsync = 20 times too slow -- throttled? To: cygwin-developers@cygwin.com References: <41A583E1-C8E7-42AB-9F24-EEC33A41EC60@house.org> <20210827202440.47706fc2fc07c5e9a1bc0047@nifty.ne.jp> <20210907122631.65452be8d021ec72259431d5@nifty.ne.jp> <20210909124115.555c6be15d675500617d284a@nifty.ne.jp> <20210909170549.506cc3c1f6029d904fece6dd@nifty.ne.jp> <20210909211940.51ef391e27d43f0421962cb8@nifty.ne.jp> <20210909214246.cd1ff1a3062fea27e51ad4ae@nifty.ne.jp> <33386baf-3b2d-d57f-2ad3-1bd328ed7935@cornell.edu> <20210911075734.aaf37697ba7db2ad14d911a3@nifty.ne.jp> <20210911113517.f74fc3ac1971bbf04c7a9bd1@nifty.ne.jp> <695ce1f4-4f7d-f3f3-6dd3-087467d67b28@cornell.edu> <20210912174849.3d38107568065a95aeb19c7c@nifty.ne.jp> <20210912200423.667e40eb1adc52461bbefa20@nifty.ne.jp> <20210913085431.8b13feaba276699fc3920a7b@nifty.ne.jp> From: Ken Brown Message-ID: <3192908a-0409-b1c3-7118-9777d52df1d4@cornell.edu> Date: Sun, 12 Sep 2021 22:19:38 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: <20210913085431.8b13feaba276699fc3920a7b@nifty.ne.jp> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-ClientProxiedBy: CH2PR08CA0010.namprd08.prod.outlook.com (2603:10b6:610:5a::20) To BN7PR04MB4388.namprd04.prod.outlook.com (2603:10b6:406:f8::19) MIME-Version: 1.0 Received: from [192.168.1.211] (74.69.128.111) by CH2PR08CA0010.namprd08.prod.outlook.com (2603:10b6:610:5a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Mon, 13 Sep 2021 02:19:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 22de510b-36a2-4d4a-e371-08d9765cf089 X-MS-TrafficTypeDiagnostic: BN7PR04MB4052: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OHdhQwUjBzUsf8oDBJwkmio59pbwBj81ZaX4fajTpHQ+h2ZfWGSurAvyD5Q5zEPiUUcHvBEmVWNbf6G+JBE2P1dnSCB3JMnS16xrMRH2Y9LJbdRc8HarfGIIjHak+9KU+Zvues5D74Gpj2p+lrfHaj+VS5vozEQKHqPT4UncmVjBsV0TwQGSA666fxBgWzZxSSUxKY1Dd5OIdgDIeoPb9ZET+NIY+Mfdx6huhYHs7t94d1EMeEH2N90sLgWYlsBKhQ9XfXqNBWaIFQZ1EvE+CL9I3Zod5Ss2FpcEpgeH8c2ZglyniJbR6xul8T7hkL//YXm73iORnmEzoq992Eb43MZmLLL+6JSnFpCehjPk2F8LQYaQW9VWAeMvXeKcGlRXlgBmCQ2xlEzTuLFGN7EXUby7us2LRa/59gxns3vGQzDl3YsrI4Ygy1ukRtAMPKKANI36ZaXrRCaoPhjkf2usKnzLphNzXqMTVffB1Slirqj1rQO8tZ48IZ4KJiHeoSxittcF/RDm4e2EaOzhmHWRdcbZTaprJnE4/rq/pRQpyTlP/cjSO9Z0ruhe63LEkZZgjmeZsHVXC2Gm3DA6I4BAeYHEMgz0ARp9OW7mXI1a/diFuax1rJrqNR03PckHDDzGoaUx8GON8twjR0Q8FtLLAcVy62eZh/D7rDoDoMejPKio027mKtuXmfR+xxJAFzm5MQnzCd95NeHf33fzkM1o0FgQsRaQYdUggelYa1EH8rSN28817lOPH2TJQ5VjfCW/tUzrjFthWsC7+IOxvSpzkw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN7PR04MB4388.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(66946007)(53546011)(66476007)(66556008)(2906002)(508600001)(36756003)(75432002)(8936002)(31696002)(8676002)(38100700002)(6486002)(5660300002)(186003)(16576012)(83380400001)(86362001)(316002)(26005)(31686004)(6916009)(956004)(2616005)(45980500001)(43740500002)(460985005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?Windows-1252?Q?XX/vs9pmqw+pET+rJg7db0Sqgo/LJz5jSrAFID+psJ5u90WjSbrvuiuz?= =?Windows-1252?Q?2Nyd08p0hQTzYBc0dO69XJZO3TmhSwHpk/xoPaZaTNS5Q8va88GOPTY/?= =?Windows-1252?Q?hdC2DkFX3YKhQgQ/TyHzmOtcPcJ3D/Ztm0oAlClOHQL4fsznBiyATMF+?= =?Windows-1252?Q?v73+OOYNaYhYz1VByhmg08eNy5spYwGzRgddBiAOks9pxeHLnSWetv5Q?= =?Windows-1252?Q?ObNBeBhr3GItSzponhIMMeSVTJsU61CVYMEd36uu+LoBHuLZtNx2y9KZ?= =?Windows-1252?Q?m/aWVUbyWVRoOFk7mRwJiompPLsKFU03Q64IcX/g3DD6fM6bymg58kKB?= =?Windows-1252?Q?CPx416zr7XoQkFc3ODG35IGPT2PtcVkhY74vnTuW4d2Hn6JNb+3gwc2X?= =?Windows-1252?Q?M40ahyzGxttysjGXynWUnXFq5Ly1WLufzuDvgQqOvQin7dL6q5CuXXOf?= =?Windows-1252?Q?WcOIBolcRJFnbiRMpOokkaZi9ARh61qBHH1bn7XbgRL+eUcxynzGRcO6?= =?Windows-1252?Q?sylWggCiFm21tHZVn93q/9HTm1wDv3HECtyme13ZgkEGp5o5oB8WZbkO?= =?Windows-1252?Q?46KaIyyB5x+cK6RGCrs1bdn5N5XWnShlc0WmL2QkhlIfBOmi271bL3cJ?= =?Windows-1252?Q?sCIjIaRfQkkEMPy3ehVjxGYxyyNqSwK2DetVMPC9waaZ3Hg0aVFUu3ww?= =?Windows-1252?Q?6wjy7rkY2m3uHlOZfgTkWhTe+84XWOvGcxI3Kdq936KB69uRQ+6+rcGn?= =?Windows-1252?Q?qA5m44ObFqVG/NzBqAPKAZJYlckitB16MbvGuBXx9jkxHJQM572+Dtjy?= =?Windows-1252?Q?s2L6AUTqtT1BRy7iJHumqYXF6PIehDsvMFIhlTnfmXSPDBw7L1veA+BX?= =?Windows-1252?Q?dcsSMsiFvC46Y1DeXu6LFSaHsZy+5xAHZMFq+9I9nhZR7iUkBU6pHc0l?= =?Windows-1252?Q?dSkwd8ZeIGiyw7UgTupvIIoklnRiLL2VmvmYXQBYbsIzVeeWxakCqQsI?= =?Windows-1252?Q?UHa6NUOzzDvEFceXewuVlN+QCG8gLRkqGE2Scdoonrx0V2cIWXqB5J3q?= =?Windows-1252?Q?sShZQ8R+26uwPTCfDkraitLFoWlL1lfH4eEYMWi0d4I1XD4QACTbdrNj?= =?Windows-1252?Q?ZFEr4ovuhfltSt10Z44nOeylwZVAA7DW6ztCgCd+n4YcFVJ1BVNKRk1u?= =?Windows-1252?Q?8ioUb7J2Q7tDXCJd0azCJdhFy4lF/nmI1m8FErb8cROoBO4QjzeC6D0K?= =?Windows-1252?Q?DIVnMtewQgF+9FOobYqtMyDZdbUewnV0uNm0lO/fUV4lH5DCQguEbYpR?= =?Windows-1252?Q?7Bkv0C8sPHKfH5zumC0eSafbBK+Cazx28NiEQHakMraJp/hz+3+SebNB?= =?Windows-1252?Q?uEUxdsTN9Luk2NJSkbelqQIEpzJou04z8v9Xm9LmeLV+QluCPkfZ5b1K?= X-OriginatorOrg: cornell.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 22de510b-36a2-4d4a-e371-08d9765cf089 X-MS-Exchange-CrossTenant-AuthSource: BN7PR04MB4388.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2021 02:19:39.6821 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5d7e4366-1b9b-45cf-8e79-b14b27df46e1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mR9iOXYpl+xhA9RmmN9pTYMKq3WRKd15JTQyqYwNNfQ8UZw3rdmY5mFaY59FSWcwOaMlOKUv3BBA/tzguqemYw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR04MB4052 X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, GIT_PATCH_0, KAM_DMARC_STATUS, MSGID_FROM_MTA_HEADER, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: cygwin-developers@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component developers mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Sep 2021 02:19:42 -0000 On 9/12/2021 7:54 PM, Takashi Yano wrote: > On Sun, 12 Sep 2021 17:46:47 -0400 > Ken Brown wrote: >> On 9/12/2021 11:10 AM, Ken Brown wrote: >>> On 9/12/2021 7:04 AM, Takashi Yano wrote: >>>> On Sun, 12 Sep 2021 17:48:49 +0900 >>>> Takashi Yano wrote: >>>>> On Sat, 11 Sep 2021 09:12:02 -0400 >>>>> Ken Brown wrote: >>>>>> On 9/10/2021 10:35 PM, Takashi Yano wrote: >>>>>>> On Fri, 10 Sep 2021 22:17:21 -0400 >>>>>>> Ken Brown wrote: >>>>>>>> On 9/10/2021 6:57 PM, Takashi Yano wrote: >>>>>>>>> On Fri, 10 Sep 2021 11:17:58 -0400 >>>>>>>>> Ken Brown wrote: >>>>>>>>>> I've rerun your test with the latest version, and the test results are >>>>>>>>>> similar. >>>>>>>>>>      I've also run a suite of fifo tests that I've accumulated, and they >>>>>>>>>> all pass >>>>>>>>>> also, so I pushed your patch. >>>>>>>>>> >>>>>>>>>> I think we're in pretty good shape now.  The only detail remaining, >>>>>>>>>> AFAIK, is >>>>>>>>>> how to best avoid a deadlock if the pipe has been created by a non-Cygwin >>>>>>>>>> process.  I've proposed a timeout, but maybe there's a better idea. >>>>>>>>> >>>>>>>>> I am not pretty sure what is the problem, but is not the following >>>>>>>>> patch enough? >>>>>>>>> >>>>>>>>> diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h >>>>>>>>> index d309be2f7..13fba9a14 100644 >>>>>>>>> --- a/winsup/cygwin/fhandler.h >>>>>>>>> +++ b/winsup/cygwin/fhandler.h >>>>>>>>> @@ -1205,6 +1205,7 @@ public: >>>>>>>>>       select_record *select_except (select_stuff *); >>>>>>>>>       char *get_proc_fd_name (char *buf); >>>>>>>>>       int open (int flags, mode_t mode = 0); >>>>>>>>> +  void open_setup (int flags); >>>>>>>>>       void fixup_after_fork (HANDLE); >>>>>>>>>       int dup (fhandler_base *child, int); >>>>>>>>>       int close (); >>>>>>>>> diff --git a/winsup/cygwin/fhandler_pipe.cc b/winsup/cygwin/fhandler_pipe.cc >>>>>>>>> index 6994a5dce..d84e6ad84 100644 >>>>>>>>> --- a/winsup/cygwin/fhandler_pipe.cc >>>>>>>>> +++ b/winsup/cygwin/fhandler_pipe.cc >>>>>>>>> @@ -191,6 +191,17 @@ out: >>>>>>>>>       return 0; >>>>>>>>>     } >>>>>>>>> >>>>>>>>> +void >>>>>>>>> +fhandler_pipe::open_setup (int flags) >>>>>>>>> +{ >>>>>>>>> +  fhandler_base::open_setup (flags); >>>>>>>>> +  if (get_dev () == FH_PIPER && !read_mtx) >>>>>>>>> +    { >>>>>>>>> +      SECURITY_ATTRIBUTES *sa = sec_none_cloexec (flags); >>>>>>>>> +      read_mtx = CreateMutexW (sa, FALSE, NULL); >>>>>>>>> +    } >>>>>>>>> +} >>>>>>>>> + >>>>>>>>>     off_t >>>>>>>>>     fhandler_pipe::lseek (off_t offset, int whence) >>>>>>>>>     { >>>>>>>>> >>>>>>>>> >>>>>>>>> AFAIK, another problem remaining is: >>>>>>>>> >>>>>>>>> On Mon, 6 Sep 2021 14:49:55 +0200 >>>>>>>>> Corinna Vinschen wrote: >>>>>>>>>> - What about calling select for writing on pipes read by non-Cygwin >>>>>>>>>>      processes?  In that case, we still can't rely on WriteQuotaAvailable, >>>>>>>>>>      just as before. >>>>>>>> >>>>>>>> This is the problem I was talking about.  In this case the non-Cygwin process >>>>>>>> might have a large pending read, so that the Cygwin process calling select on >>>>>>>> the write side will see WriteQuotaAvailable == 0.  This could lead to a >>>>>>>> deadlock >>>>>>>> with the Cygwin process waiting for write ready while the non-Cygwin >>>>>>>> process is >>>>>>>> blocked trying to read. >>>>>>> >>>>>>> Then, the above patch is for another issue. >>>>>>> The problem happes when: >>>>>>> 1) Start command prompt. >>>>>>> 2) Run 'echo AAAAAAAAAAAA | \cygwin64\bin\cat >>>>>>> This causes hang up in cat. In this case, pipe is created by cmd.exe. >>>>>>> Therefore, read_mtx is not created. >>>>>> >>>>>> Confirmed, and your patch fixes it.  Maybe you should check for error in the >>>>>> call to CreateMutexW and print a debug message in that case. >>>>>> >>>>>>>> My suggestion is that we impose a timeout in this situation, after which >>>>>>>> select >>>>>>>> reports write ready. >>>>>>> >>>>>>> Keeping read handle in write pipe (Corinna's query_hdl) causes problem >>>>>>> that write side cannot detect close on read side. >>>>>>> Is it possible to open read handle temporally when pipe_data_available() >>>>>>> is called? >>>>>> >>>>>> That would be nice, but I have no idea how you could do that. >>>>> >>>>> Hmm. Then, what about PoC code attached? This returns to Corinna's >>>>> query_hdl, and counts read/write handles to detect closing reader side. >>>>> >>>>> If the number of read handles is equal to number of write handles, >>>>> only the pairs of write handle and query_hdl are alive. So, read pipe >>>>> supposed to be closed. >>>>> >>>>> This patch depends another patch I posted a few hours ago. >>>> >>>> Revised a bit. >>> >>> I don't see how this solves the problem.  In the case we were worried about >>> where we have a non-Cygwin reader, the writer has no query_hdl, and you're just >>> always reporting write ready, aren't you?  Or am I missing something? >> >> BTW, we could just decide that always reporting write ready in this corner case >> is acceptable. But then we could just do that without going back to query_hdl. > > The various combination of cygwin and non-cygwin cases resuts in: > > W P R: current, query_hdl > c c c: OK , OK > c c n: NG , OK > c n c: OK , OK > c n n: NG , select() always report write ready This is the case I've been talking about. I'm sorry for not being more clear. > where > > W: Writer > P: Pipe > R: Reder > c: cygwin > n: non-cygwin > > * Reder requests larger block than pipe size. > * Writer cannot be non-cygwin because we assume the case > that writer uses select(). Ken