Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp252755pxa; Thu, 27 Aug 2020 00:57:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyncMikJgYxjYXNvXYJe9hpaVgb2PZRE0FbDgjuKtlWBNJckXndFV1uFaioLYl9rGFcAlb7 X-Received: by 2002:a17:906:f848:: with SMTP id ks8mr5100817ejb.5.1598515041928; Thu, 27 Aug 2020 00:57:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598515041; cv=none; d=google.com; s=arc-20160816; b=UYa5jcxTEKo0edQxVSN9QBPNPGRGW+xFOJ4D6whYTNT0sNfOLKYGOYmw3bLvnasOOG x211CSOmh7RptZMKgW4x+iI2ChEvQZdySAVRKyc4bS2rfQSv5Ng74u+heg5J58fkg8r9 l1wbQ6T2y0Tvn7TjPvoQTC0myKQV/Tui9W6aq2yJps85fAcsn45nBc/A5Hu9TCjSP0Sd 6gtEXtrHECocMLgl4O2e908IDxdsP6/1RFBXJRT4nyo7IhhLIY22mokcAEHMJODt2YKT advn93bOz4GRPuCZ5pyF6HmcQDagPDPBimQxwKj870gSTNQXdLC+XEE0JoElDayaMuGQ h4SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=3NxNjEm/p/rY80EFzOxwC/fD37e7Y8ZDy3H6saRIl0w=; b=WHYSsvQwgGxyjyqtXbPJRZzaXJBIvpABEi1/3f8dU2xCXyGIQ3sHVfP/BbBoI+dwS/ SJo3WvKg+jUNXbFGysdqhpVkLLxWJpAm4z7RBP906xf2r7b+goOVPM9y5KmkXgII7Q/V lr3yWiNgfiXTSjYRe3rpFIotFVvwtIUwu9owQdrIKo5kmid1F2EV9RMu9jZ46X1ZBIsS LCP4C3MNFvbLSIbXIJuatZ4LRuNMkaJIlyPcyzRwisQ0j6x1q9+BLOGNs9N/eo8mMeWm Fzwi9G7B1YTAj4/Ln67eIEWVAyey/VAcGGtwwCSdXB3SZnnexx4ohfdbgKnv4L/ZdssG aYsg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pj27si881655ejb.534.2020.08.27.00.56.59; Thu, 27 Aug 2020 00:57:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728587AbgH0Hzq (ORCPT + 99 others); Thu, 27 Aug 2020 03:55:46 -0400 Received: from mx2.suse.de ([195.135.220.15]:55712 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728570AbgH0Hzj (ORCPT ); Thu, 27 Aug 2020 03:55:39 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id BBBF2AD2E; Thu, 27 Aug 2020 07:56:09 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 4F1A71E12C0; Thu, 27 Aug 2020 09:55:37 +0200 (CEST) Date: Thu, 27 Aug 2020 09:55:37 +0200 From: Jan Kara To: =?utf-8?B?55Sw?= Cc: Jan Kara , "bcrl@kvack.org" , "viro@zeniv.linux.org.uk" , "linux-aio@kvack.org" , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] aio: use wait_for_completion_io() when waiting for completion of io Message-ID: <20200827075537.GA15885@quack2.suse.cz> References: <1596634551-27526-1-git-send-email-xianting_tian@126.com> <20200826132330.GD15126@quack2.suse.cz> <26ae9330.63f4.1742b70dd88.Coremail.xianting_tian@126.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <26ae9330.63f4.1742b70dd88.Coremail.xianting_tian@126.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello! On Wed 26-08-20 23:44:11, 田 wrote: > thanks for your kindly reply, > the normal wait path read_events()->wait_event_interruptible_hrtimeout(), > which will call schedule(), it does not account IO wait time. Not sure if there isn't some misunderstanding so I'll repeat what I've said: Yes, above path will not account as IO wait time and IMO that is much more common path which should be accounted as IO wait time. So I think that without fixing that path, fixing cornercases like you did in your patch is rather pointless. Honza > On 08/26/2020 21:23, Jan Kara wrote: > On Wed 05-08-20 09:35:51, Xianting Tian wrote: > > When waiting for the completion of io, we need account iowait time. As > > wait_for_completion() calls schedule_timeout(), which doesn't account > > iowait time. While wait_for_completion_io() calls io_schedule_timeout(), > > which will account iowait time. > > > > So using wait_for_completion_io() instead of wait_for_completion() > > when waiting for completion of io before exit_aio and io_destroy. > > > > Signed-off-by: Xianting Tian > > Thanks for the patch! It looks good to me but IMO this is just scratching > the surface. E.g. for AIO we are mostly going to wait in read_events() by > wait_event_interruptible_hrtimeout() and *that* doesn't account as IO wait > either? Which is IMO far bigger misaccounting... The two case you fix seem > to be just rare cornercases so what they do isn't a big deal either way. > > So I agree it may be worth it to properly account waiting for AIO but if > you want to do that, then please handle mainly the common cases in AIO > code. > > Honza > > > --- > > fs/aio.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/fs/aio.c b/fs/aio.c > > index 91e7cc4..498b8a0 100644 > > --- a/fs/aio.c > > +++ b/fs/aio.c > > @@ -892,7 +892,7 @@ void exit_aio(struct mm_struct *mm) > > > > if (!atomic_sub_and_test(skipped, &wait.count)) { > > /* Wait until all IO for the context are done. */ > > - wait_for_completion(&wait.comp); > > + wait_for_completion_io(&wait.comp); > > } > > > > RCU_INIT_POINTER(mm->ioctx_table, NULL); > > @@ -1400,7 +1400,7 @@ static long read_events(struct kioctx *ctx, long min_nr, long nr, > > * is destroyed. > > */ > > if (!ret) > > - wait_for_completion(&wait.comp); > > + wait_for_completion_io(&wait.comp); > > > > return ret; > > } > > -- > > 1.8.3.1 > > > -- > Jan Kara > SUSE Labs, CR -- Jan Kara SUSE Labs, CR