From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2110.outbound.protection.outlook.com [40.107.96.110]) by sourceware.org (Postfix) with ESMTPS id 14A413858D34 for ; Sun, 12 Sep 2021 21:46:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 14A413858D34 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=hfaNarnUl5o/sZS/BuE2xLa5Hph6vhNT0izZ3OkFL8vCoSG6yLbh9i3VjjQQT11KOddqUTEGTEO73vi5vq61IDu9tfaPzrm7Vcklks3Uzeu0n2xBSU3FB1KV+skoks3FjAX9c7NuMORrAOkGpUbXsTCq3sX3+3M7sFLUlU3kV9u8blU5PUdYgs6qZyTog1VAz7+6liObHZgfGV7rzmR2J9ILOYFlnYDbNqzSZXKNIPEy3YK2rl2cAQIRxtfVSykg3lTSpnacbk5ND1P+PHe8UKz9OX232+WXvj0h/i7BMTV9R1yYRZNTFro69b1O7RlKZPOwpRYRTZBeaKFc2hooEA== 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=m+XZCu/POi99+v6grZWAZi1Nw1W5fgp9Y9CHIRPeL7w=; b=B8GDhALf9GdPSJCsQH12DJjRs/7lu05C/KQpCMkJLot1QZngy/lo+xeCAJTKzhWnlq5MunJe0xuoOfYjt95w7hrzygR2rzTKE4POVotGOH/tPur6RNusifs1igfwr6vu8eiQjf6rIohh5Sm0S8SuPlfE/lj/IMTsBNfz5SPiSpjSjuNSEO1/RDcUsFDUt73yxipgsPHTQm7neW4nmZce6V+gfXkAglOHco2iMgj6CwSzyAFp0R+v4YydBYf94G2fRxudOyyz3OHbQAK5VnO80KE+xZKv2Sp70sx2ixb7LvhGPb48e9H4Z+aM4HfcJQJ255aUVCxPtpKuBRSRGtGn6w== 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=m+XZCu/POi99+v6grZWAZi1Nw1W5fgp9Y9CHIRPeL7w=; b=TH/4hbjvmA9IWe9bBRRK9d9xA9hvzd/NThwj8Zw36ybCa+9PhlZZkQgTLldgHrEKPjPTVKwlrbrLoFAGPj6jI9e1YHIWItG6wXizLGa0vZapyfVnChUoiiFEPOLplCVNh3+BUquPPXKtvgUBR4r8iAFMcDfxF+Bp1WrmPmCdl40= 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 BN6PR04MB3730.namprd04.prod.outlook.com (2603:10b6:404:d6::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.17; Sun, 12 Sep 2021 21:46:49 +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; Sun, 12 Sep 2021 21:46:49 +0000 Subject: Re: cygrunsrv + sshd + rsync = 20 times too slow -- throttled? To: cygwin-developers@cygwin.com References: <41A583E1-C8E7-42AB-9F24-EEC33A41EC60@house.org> <3b560051-ab27-f392-ca4b-d1fd9b5733b0@cornell.edu> <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> From: Ken Brown Message-ID: Date: Sun, 12 Sep 2021 17:46:47 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-ClientProxiedBy: CH2PR18CA0032.namprd18.prod.outlook.com (2603:10b6:610:55::12) 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 CH2PR18CA0032.namprd18.prod.outlook.com (2603:10b6:610:55::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Sun, 12 Sep 2021 21:46:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d65003ed-22c8-4ca8-576f-08d97636d318 X-MS-TrafficTypeDiagnostic: BN6PR04MB3730: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +lAbHv+SKGbCXchfs2TJzK+JRau4GJSXb1jN00ZcpsS+fJUYWdYqSzyUlOp6pYTjAexgRZK40nMFxNNkrDxKgeDW2B007hifm2KVwghBgt43eJeZlf0sTEW3r0nfqYFg4tINFx/RigKO0pw+EowyOvHDEBzEniFYLA08nVm29pImfzYwfT4CnjGkZuE+dxcbigAjjaElx0AxFqxo+UEL8r5/UegrNmWUHU67l+BBNwF2eznLgAR3OxTcTo17uz2z9B3dyxH/BBksXg3cQ3DWHxoRGClfUqiuoku2Emf/E/SI1/ZvFlEIx/FvRKa/8tsEwYHErCM39mBCZ//zLN4VDFHacLgbt5y76TaForysfHFqJvnQOYeHw/jL+q1iLTex5TjAdVhQEbvXhnbwSukziKO/VuGuSqHHITSxB3xMUCT89eW6F8dq+h1beII3NHnFvfvPt38Ffucb00vYX2V6Tr9OTJqy1ySAnrF5RBmzFLKLLTPfaEwmKaPROCJuDw6fLBDHPU2rx9Gli2hgQrh8CFQYUhMQDKTQ/rddDucIuFTb65YCLiYNokLNLvH6E2df2jNzUsKELRlCwxFvObh+A/jZ+WaESDcNc+UnJBGs+rk2PgP6hMgvNxBR4L+f8WVThQtNnEMpvjWLxDcux1lXuRD+oy6sLydZHF2aXrH7nIx8G60Ui0DyJsky1ZyP3WuuRz76LWjLFlZAE2R5vl9yeSGOA/CYc5wXRqo3jLBWGiFIpnaIhx8dRX5wLto4Zq0JdVr7NUEpxEwTDY9QVuRE9A== 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)(136003)(396003)(346002)(39860400002)(376002)(6486002)(6916009)(16576012)(8936002)(31696002)(66476007)(66556008)(66946007)(316002)(478600001)(26005)(75432002)(31686004)(8676002)(186003)(36756003)(83380400001)(2616005)(38100700002)(956004)(86362001)(2906002)(53546011)(5660300002)(45980500001)(43740500002)(460985005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?Windows-1252?Q?b4Ltev8BBIvGn942T30wQRxAxd1gySTtBPxIlEof9RD+gxEOAIuXPBj0?= =?Windows-1252?Q?dfPAs9r+bQq0P3HUJyUmy3aRsGrxIwr9oR4HRb/5ybGDASnOVFsJOulJ?= =?Windows-1252?Q?9WOq+xAzJjoOtIvNpSHUjsRs8LYks1eNckaqg70eQZ5JaUDoufQZO/Gc?= =?Windows-1252?Q?OpugMce+4bQFrIF3ePI75uheGuI4CMrCag+XYWYXl3BFbeehxTmSp9QE?= =?Windows-1252?Q?pESSHNGibsdR3lbW5CmTJHqUt71ymC11XaOVeJ1rCRmWosP78d8/Dunx?= =?Windows-1252?Q?W/R6YjMewhdnu9UAngdLOCEgNihSG+WUPECcT6ecQ8FWLk2zhCmwuEnT?= =?Windows-1252?Q?ne4nb46k+rHF1wqisU9HMSU6iLRGUoK+09ut7+kFBRzhcGyBI67BkcZ/?= =?Windows-1252?Q?Z0NlWYx/dP2fAxw6ucUi15OZlacs6cXH7PYzQeah9y+ySwDUCiCM3i8m?= =?Windows-1252?Q?2htmcy5qE7wecycsRaNcrDpy3vWciHTt92TcHpBp/2z5cUxKfYsu1X/0?= =?Windows-1252?Q?6lYNurLDFIrpEK9hpkviVZ60Z5GRZs+X0hYEV3p3AszCjLBxYUpylk8F?= =?Windows-1252?Q?cXsJbPs9BmRz3SRUAkyhWI3PsoT43acuRVi7PfMaTpaQP8PIYgtPh+M3?= =?Windows-1252?Q?BWJvUYNJYz8RjJdbHPmG5AbtTHPsNRAWc9OCEbtYHgLppmUa/uAt8E3+?= =?Windows-1252?Q?k6EKxX9W+K2A89OvHy1yXnBYtvDlQXRWZ+8xL/09sMLCrAI8MBosfuR0?= =?Windows-1252?Q?dwwvg95u8ihFrqmeiHNUwqQGYcSkJFF3FjLYvNFSuwTsOlt2VoFqsaut?= =?Windows-1252?Q?N21e0TO2ak3hjRpiHtoYO/euT2qvHN+caW1i7JEKmKjYk0BWJduTL7fd?= =?Windows-1252?Q?wo+my9kNG9I7YZFvDzuUpiEL9Dhnniu403LAzTGm+ntC/1lgRYUIg/xC?= =?Windows-1252?Q?YVNE8zcU4IyNJOgKXuegA/AhZuW291L7GSlNXerYUvYVPXYmS8wlxmRi?= =?Windows-1252?Q?/ETjCEMHeMgG0wDuIOugwH/2GGRs6JZXk7pyv9ZFvg+RPrh+T51YK/Q/?= =?Windows-1252?Q?dcKMA1bZIVEAvLefZqHvJ3OHvMKdVkZxiIzJDIrdEQvmglnSdddWr7G+?= =?Windows-1252?Q?w0C0YWXz68JyqaK6V9sThgprCijH75Z6XdkMw4FtsoLz7lzP8iC959BR?= =?Windows-1252?Q?Hw8kpBuctSq8m2UWoVzLLFe57k9HTByFAKprT/v5IspXjVR+tGjiBCw/?= =?Windows-1252?Q?gbwABtSq5C6vZ6eg2/im52WWa4ddcMBMiZ2Pl8ePKHy/NZ/mtExknyDa?= =?Windows-1252?Q?eJswvpzUlCoAjM2EYzgWzYgFeiZDSsJIGsiIaFIWi712T8fnPNnplK5b?= =?Windows-1252?Q?bPx88vWSLoZ5IjPoetNoBMJ3Mya/xvg3RJ594U9jWqd49Strhx+9OnU0?= X-OriginatorOrg: cornell.edu X-MS-Exchange-CrossTenant-Network-Message-Id: d65003ed-22c8-4ca8-576f-08d97636d318 X-MS-Exchange-CrossTenant-AuthSource: BN7PR04MB4388.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Sep 2021 21:46:49.3564 (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: SLrMB377UjYOk/pIIjihGX0YfodYchrp8kdWinN2PVstoAZYwh7DrU9P2CuxfH14a/QBBjhCcDuSjg9pZI66bw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR04MB3730 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: Sun, 12 Sep 2021 21:46:53 -0000 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. Ken