Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935196AbcKPWOT (ORCPT ); Wed, 16 Nov 2016 17:14:19 -0500 Received: from mail-db5eur01on0093.outbound.protection.outlook.com ([104.47.2.93]:17743 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753942AbcKPWOQ (ORCPT ); Wed, 16 Nov 2016 17:14:16 -0500 X-Greylist: delayed 79518 seconds by postgrey-1.27 at vger.kernel.org; Wed, 16 Nov 2016 17:14:15 EST Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=MPatlasov@virtuozzo.com; Subject: Re: [fuse-devel] fuse: max_background and congestion_threshold settings References: <87oa1g90nx.fsf@thinkpad.rath.org> <64a57faa-d3a6-a209-8728-723ed7f37c2f@virtuozzo.com> <87fumrmdvn.fsf@thinkpad.rath.org> <716677ab-f962-1628-205b-2326219f4487@virtuozzo.com> <877f83mb2v.fsf@thinkpad.rath.org> CC: Miklos Szeredi , , linux-fsdevel , LKML To: Nikolaus Rath From: Maxim Patlasov Message-ID: <7828c809-f699-c16f-a1aa-24ce839547ff@virtuozzo.com> Date: Wed, 16 Nov 2016 12:41:03 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <877f83mb2v.fsf@thinkpad.rath.org> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [162.246.95.100] X-ClientProxiedBy: CY1PR21CA0004.namprd21.prod.outlook.com (10.161.247.14) To HE1PR0801MB1851.eurprd08.prod.outlook.com (10.168.150.147) X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1851;2:jlncRU95kovkj8DkvqRjQHoYfLgN0kfwpVVzH/9ppczjbOY47wC+LsKWU906lFBWokSj+0LVEreKVagLtowQhnWXpfuociaDJGOHNL0rM4HSfcX+/kQQ8cHXscrRJXjJaOrr1wACV7uN0yAvDO1m7TwYw9sDfryZQkp6rGJ7Qmo=;3:cTMXwDotdQ9HR4gl299YNt7LiTTj1hC0mOXkGfEGKHhFsE3i7KlJHh3YyPPfacLBlY4Cp5M4F351kqayPEB6pjEETLzBketLY+gYRuOlWUwXTKcoaiHcUdrZHQryfNRjLaJIvp66LtAgHkMU9xNWln3mBzlEvqTcozDSR9Tvbrg= X-MS-Office365-Filtering-Correlation-Id: 7dbb643c-6fcc-495f-359a-08d40e60ea46 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:HE1PR0801MB1851; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1851;25:MCkJg+W9LGAS/13QWo/+o3FtRNgQpJtO/JrfDKbs+TfbsCLX/10xD7vpm/fuGD9JBFpioCSLfgK7bO0vWneEfI+/hWcsP7crTyn47dSixDxj9aO6HsVim8yDaOnge1zwFxHMwIcb67z1eFyNkSaVZYajJWNcySD4qUSIVSH3Q2501eDWQrk6mdH/iW2GxE9HzL2PBL/Jkbi2WZlGoxA6Cp6Y//fBSu8g6aKYzCdyQnLoidGRnjhYg1pQbruStjXmnpqYAHBx+p7Psnu1zk6zzG7Avrfquaw72MKDAQmDdNINsrtrHOjjAiM7D8Y2meDosTBYswO7FddFSwlCZe0CHLQf4GpJY/xm3aQS1gqtuQ8HTkfwgfY2LedmdzsJVQ7A3+bP80CDhdMJs6w+1TftrHsK4myp77w0oVczfaAvzXDjghcn57JjN8uXxegMh2VIx9HVlrcJUpwn9Z+FJZvrWeor3mHtOuemrREclppUgrf3jcbtu0VBCTEUYN3ip8zcQHvEbeqtK7XNIs4cohnghcX/Dk8yjl9yX++WjyHqgm6aIpj7dbptbXmahWLnLxAb7LV5B3mRw7EDTIES+qXPWPQXIl2SOqslFlXP/DH1u2A03qkiIOO1KnibiieEKypKs1MpNd5LrjDT6HylBgEHGrcT+uW3rRruEw8vzZbc4051S7Tum20G+asVuZdue7T+ABRzM8T4v/LtAB4RN4BRbRK9q2wIb+/GiSMtEmwoPOy3K8ZjGfcTrysJmMrLm/+HPz9fqydTHc4ewDdOgdhdMg== X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1851;31:s3Til7r1wclrYIA0n3kFbJCemdqZFiUfVypNxAdQSjqpmjCDCum90VfBjOvQ2563KlvdLWYoS6/z521Qaw2xQXdypXvPzcHaeza3KlcCo8fbUimFgNBpB461Cs3nlLpCYKPYjQ+JKUBF2I3ukoBluO09DRNPLU2KYSL8QP7O+O3HLBQ2oG23c6dXL39Yxv4j47pgc7RJ25mauC5YgcQFk2HjUNLkGIT3V3s16We2Tq1lHfV+hUz6GTfYly+84AkG+RZsd1Xsmb/XouehDDnr3A==;20:UV4KYV19U+pbHxk/TeZwJqIjKb+N0c9JHDvdQnilG9N6VJM2B6+NbprpsdViQhIVbcV2Q/0E9Wq7GMdkrCTFFy5vEfy49FSNhONzcwHPCMWau+opZP24d1o55+ECuYRNHYzJD/XauQPp69s6kXa/p9NSAMGtX3zpMIGO9nWbeQ0= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6060326)(6040281)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6041223)(6061324)(6043046);SRVR:HE1PR0801MB1851;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0801MB1851; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1851;4:H2hLNh0TqjgGsv8nmxtAlH8s03UWd3k9K3sladbybEU1p4aJfnZ/eyOIr0KqpH8ee6wTEF/E3VqvZP3+NVSvI2Ag9rGTY1lj2TCyNnVE6ZEmxRlTgK8+VSgwvocD5emshAGCmg9CAacMFi9qb8yiuwTQoVSyZrcSyB1XVo4P/yRJg/ijsA3A9htUrGjZ49tQGE6IofyjqiiogNXsgc95/D+mvjMrU4vq1sm3/fUgTY4S6vM/6ARFx3jZ70opbHwYKK1utjmgsHyDzhugYEtug+jYvrMERrV7p29MOOPZlSz4XOWHozuTEXToTBt9kJ6lPbP+Uz8cawUeKxAB51rZt90qXXqePZUEWDZHt8PprmogJ+3QI0HvedS6wf6uZNrIdIa+GHh5i7FTbIhZ3EioCCHLpQYAG4ExhXvSqaj9Hl0NMQ2mktPpTV2E3WIGJ3yH3UFRQ5pwnViCswDHIGh8juT3bAt99KzyNy2nAItK+ts= X-Forefront-PRVS: 01283822F8 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6049001)(6009001)(7916002)(24454002)(189002)(199003)(51444003)(377454003)(8676002)(54356999)(50986999)(80792005)(2950100002)(42186005)(68736007)(65826007)(76176999)(97736004)(5660300001)(4001350100001)(66066001)(50466002)(189998001)(64126003)(65806001)(65956001)(6916009)(6666003)(92566002)(47776003)(229853002)(2906002)(23676002)(110136003)(4326007)(105586002)(101416001)(3846002)(31686004)(230700001)(31696002)(77096005)(7736002)(81156014)(33646002)(36756003)(6116002)(93886004)(305945005)(81166006)(86362001)(106356001)(7846002)(83506001)(7099028);DIR:OUT;SFP:1102;SCL:1;SRVR:HE1PR0801MB1851;H:[10.161.30.31];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtIRTFQUjA4MDFNQjE4NTE7MjM6VWtqVDNsSXk0RXU5WkRrblp6Q3h2NklV?= =?utf-8?B?OXVoM1dlMERlOFRDNG80ZlJ4cEZwU2hJT2o5ZEdSU0ZmUUhyekJzc1huM2Z3?= =?utf-8?B?ZDAvQS9TbDMrcmx1dWh1dXhUYWpMYXIyN0NXRkkwdkdISWJLWElIdkd3ZkUv?= =?utf-8?B?U0lGS20veWFqanRMTTY5NnBibnZkclV4TU9wRTB5WG5sNHVXWVNQc3dQR21L?= =?utf-8?B?OEdia1JPeEZyV0h4NzRFMFF2WDJFaGRJdXAvZUptWEFmS3NocGltaktVbERF?= =?utf-8?B?bmRwRW5mMFJEVE9FYm5PZ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Emo5fFW8nn8MO2u23omvbbm9LJ2SBZdkzrJPrPPkUKYzQP4Q5TtNqMFKBtv6XLXX5x7q/jdIm7MAJNJTm0wDRpS9jefCbaHzsjfoyZ43atm/03+ovfAJCB;5:qfB1TXD0yHgc7DXrU1Sb2dZgrNETk856lrwgl8YHJkHBNgOfDmQnb68eYHple6XMr/wT82c/kha+AT0HaXSzkUDq8xmhlhmgxop51PD+UQPkOnTU8AKQ70viQYlrtISEuOMctAvJjte8cgo56xH2hRVNcxhCdRkl5eohIA6ybPw=;24:E+0wAYz/hsP5K9x6tuIJsCyjh+RS2DnPXuYXEewpYDX3pAoioMrfk1N9hy2E0HOFsrni9HqjtUGSjLVEDS8Ly+i+hSzspoxspdtPH9Os84o= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1851;7:4do/Xde6lY7JfQg1q/pG0RcKqJoX3aWRUV7furLWWzolHGyw6x5bwy7oSK6xBUIdkQBtFHhHAfiEarqV4+pKRMAC8WHnt5T0IJwTMiMBOwniT7dgir1VcURm6BDhjbFKCcqdvzn3PY4Y7fs37CQMRph/UGsAw3MOInjXrHmt4UgKv6FfBb7CJGs09d5psnOL4/HK4MWvpIClIlt8iBuCdVa2/fUm4m1u0ufRlhg1HS9kAA2bO339esgVSOAW1bBS8D0LKcc8ungMh9uO44Z3K65sTUUOg7n99wtwrRtWlogWr/rwlhZbGUyaPtbTOoQBvpa0yO65O78d/B59LM/gCU7tffH3SwhUe8L/T/z/QJc=;20:N0lCXvlMMT+UC1CkQmmNTaz3CRYgVfme0FFaf3KGNuzRcXtC11aXxbM+cSzAbDPFeBkPTUnth7oATN9zOzKDWTv+IHiW/rVqp3y0jIfya40QQM1hltU9yK2ZmyUx84aLUFIxZH4Ru+EvTZGcNii2bQhCucjt7gus0gr7fxwf1vM= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2016 20:41:16.3390 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1851 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3565 Lines: 74 On 11/16/2016 12:19 PM, Nikolaus Rath wrote: > On Nov 16 2016, Maxim Patlasov wrote: >> On 11/16/2016 11:19 AM, Nikolaus Rath wrote: >> >>> Hi Maxim, >>> >>> On Nov 15 2016, Maxim Patlasov wrote: >>>> On 11/15/2016 08:18 AM, Nikolaus Rath wrote: >>>>> Could someone explain to me the meaning of the max_background and >>>>> congestion_threshold settings of the fuse module? >>>>> >>>>> At first I assumed that max_background specifies the maximum number of >>>>> pending requests (i.e., requests that have been send to userspace but >>>>> for which no reply was received yet). But looking at fs/fuse/dev.c, it >>>>> looks as if not every request is included in this number. >>>> fuse uses max_background for cases where the total number of >>>> simultaneous requests of given type is not limited by some other >>>> natural means. AFAIU, these cases are: 1) async processing of direct >>>> IO; 2) read-ahead. As an example of "natural" limitation: when >>>> userspace process blocks on a sync direct IO read/write, the number of >>>> requests fuse consumed is limited by the number of such processes >>>> (actually their threads). In contrast, if userspace requests 1GB >>>> direct IO read/write, it would be unreasonable to issue 1GB/128K==8192 >>>> fuse requests simultaneously. That's where max_background steps in. >>> Ah, that makes sense. Are these two cases meant as examples, or is that >>> an exhaustive list? Because I would have thought that other cases should >>> be writing of cached data (when writeback caching is enabled), and >>> asynchronous I/O from userspace...? >> I think that's exhaustive list, but I can miss something. >> >> As for writing of cached data, that definitely doesn't go through >> background requests. Here we rely on flusher: fuse will allocate as >> many requests as the flusher wants to writeback. >> >> Buffered AIO READs actually block in submit_io until fully >> processed. So it's just another example of "natural" limitation I told >> above. > Not sure I understand. What is it that's blocking? It can't be the > userspace process, because then it wouldn't be asynchronous I/O... Surprise! Alas, Linux kernel does NOT process buffered AIO reads in async manner. You can verify it yourself by strace-ing a simple program looping over io_submit + io_getevents: for direct IO (as expected) io_submit returns immediately while io_getevents waits for actual IO; in contrast, for buffered IO (surprisingly) io_submit waits for actual IO while io_getevents returns immediately. Presumably, people are supposed to use mmap-ed read/writes rather than buffered AIO. > >>> Also, I am not sure what you mean with async processing of direct >>> I/O. Shouldn't direct I/O always go directly to the file-system? If so, >>> how can it be processed asynchronously? >> That's a nice optimization we implemented a few years ago: having >> incoming sync direct IO request of 1MB size, kernel fuse splits it >> into eight 128K requests and starts processing them in async manner, >> waiting for the completion of all of them before completing that >> incoming 1MB requests. > I see. But why isn't that also done for regular (non-direct) IO? Regular READs are helped by async read-ahead. Regular writes go through writeback mechanics: flusher calls fuse_writepages() and the latter submits as many async write requests as needed. Everything looks fine. (but as I wrote those async requests are not under fuse max_backgroung control). Thanks, Maxim > > Thanks, > -Nikolaus