Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp119342pxa; Wed, 26 Aug 2020 06:25:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrJ7oU34iH5uINwKzYcKBMeztVNZW+hbc45MlQ/AZFukhmu2ASo8itHzQhbOnS0oIUc7Tc X-Received: by 2002:a17:906:fa15:: with SMTP id lo21mr16302107ejb.42.1598448317941; Wed, 26 Aug 2020 06:25:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598448317; cv=none; d=google.com; s=arc-20160816; b=Y2/Mdxwx8zsuzgVNOfaBRN5ACH2RnH2Nb9JBGXQZBJBom4/DOd01tMsRcBZwW31JHq 4CPv5pLCj7pJ4VrCp8tBU7i/lodOYr9VUf3zbBUhu22z47aAKPrn1fwfSsrQ5Pf2vgz3 OJJff0oHbRyP8upVxhyw12R/ztK/IwOm3hgjWeVPIS76Bfld5qukid1nANhtu+h1D9IL VfIlH5MT+GNdKBN2vQmPa5camIXtUxcUg49Ig4azCfXOXgMXs9F75EPuIpqjMMbqFEmr elPpHxwEiDcYIVY3Lis23STu/e5wgBKuIhv6E3BEo3VDAUIW50jtrtScMEFNIkF+SRE5 vkDA== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Znp5zIRGyeQED5LF2xUbWnPDZ2zT/A2QSLyMJauLYo4=; b=K2J+AFUGY+cg9clCT+AYy6w6uEdMIaXuJTuqjfjiVcvlqY/mwQIhEGzvXbfhPLJ326 065e7BIxldSbL4hgHhCfg4CnOt2cLFrpOedXAz9uXmU2pumJ0bdJRHzSJtSFaiIX8kzy rQanGm/XWKvJMtQC4rjPBOZYnmB4JBIlKHtQSUvbCJHODUU03iBRs0/QSYB0IzlZfghI tg4dbkLnxidrr4sCORGUT1PXrUT/xFdv1NnNCiimKa/Il89eOGVQdquyqVvjTx66+3b+ 0L8IW3/qBy1dgGlQ6mqNfEsgUAXaTlsg02DIQtpyDR60ZwlQi+/oGUW83a7YCmuNeZqc EtYA== 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 e5si1576706ejc.182.2020.08.26.06.24.55; Wed, 26 Aug 2020 06:25:17 -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 S1730163AbgHZNXh (ORCPT + 99 others); Wed, 26 Aug 2020 09:23:37 -0400 Received: from mx2.suse.de ([195.135.220.15]:47064 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728132AbgHZNXd (ORCPT ); Wed, 26 Aug 2020 09:23:33 -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 0E079ABCC; Wed, 26 Aug 2020 13:24:03 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 33FB61E12AF; Wed, 26 Aug 2020 15:23:30 +0200 (CEST) Date: Wed, 26 Aug 2020 15:23:30 +0200 From: Jan Kara To: Xianting Tian Cc: 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: <20200826132330.GD15126@quack2.suse.cz> References: <1596634551-27526-1-git-send-email-xianting_tian@126.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1596634551-27526-1-git-send-email-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 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