Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp768071pxb; Thu, 17 Feb 2022 14:26:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJxnXskrxQO6i0IBFWSWrSufXClqAD2co9x80qw7i7ejF+IsnrbktVV+29T2xX+r4Dyl/Ob/ X-Received: by 2002:a17:902:ce92:b0:14d:49f6:bc7 with SMTP id f18-20020a170902ce9200b0014d49f60bc7mr4541139plg.128.1645136789373; Thu, 17 Feb 2022 14:26:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645136789; cv=none; d=google.com; s=arc-20160816; b=y0yxQ+k6/9Rsenc4CvvYQpOhe5Pa9cT05g5hgw7CtwD2DwPaPB4RlKbVLmPkjAxkV/ 0TOus47mQ2xPXlwg6tTPxH1PfnnD/CNjop+5VI+5Pdr1dpLKlFBWOOP/BUHuxvr7+ETW pr0F8Nx2wLawAB8Bywqo1sb7M7g3HWG3k/MrmXyvv2QAkRt37hVpoEHMGpYMml0SIUv7 99BoiZeW8dPRIegT8ltEfrNQGudneQrup5pCT/vV/hj/yHbo+HBCe8oPSKvGTbCALqvr Ke8SwBA2fRSHc2SAoGmMPod4zAZtO0QlSWTyKZC/tpDQk89aELpOcO6C+QrmMog6hZEw ApeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=zpKIeLkDDJr96WYU6HeQeRGD3NuUHah38VQkaFsySN8=; b=aLYrkE28yCuV4yEXLZ1uj44sI3+glcd9W/04twcZopMtT7yNQyAdkmNNV08EoZ1zJ9 oEZRFuI1ePf/TvanS78swJxqz38MPj96e5pziMZjyex8pbRW/00+zkaeJ94fXqzGXkpM YylMqO/xjbJfGF3HwL1wTdd39yx1/8aY9qThwc6OsO3kJObj0dfqPfn9X1J4GDFUhnWT mjq5eba7OotKoD4iKK0D++V4CAzSLsoMEs0ZpWhiCmH1yFLtIzYDSKouTHIx7qh/dgGO JPmdgLFMt1lXg62qSik4W5hQEWGwBPPgdP8EOyTAJ7bF2Q2YGkneEAU74hj31vm1uP70 2B0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LwvbAGf9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d17si22530626plh.92.2022.02.17.14.26.12; Thu, 17 Feb 2022 14:26:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LwvbAGf9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238347AbiBQS4D (ORCPT + 99 others); Thu, 17 Feb 2022 13:56:03 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:34474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237519AbiBQS4A (ORCPT ); Thu, 17 Feb 2022 13:56:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A080758E6F; Thu, 17 Feb 2022 10:55:45 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3C5B361B8A; Thu, 17 Feb 2022 18:55:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02E7CC340E8; Thu, 17 Feb 2022 18:55:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1645124144; bh=Rh0qZRyhLF/JeJYDSRhXWN0tLJc2VU+e0gkrEgt5rFo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LwvbAGf9J25gZA48/mDNJ6DibV8IANCyxD6WtW/RFemLIbgE+LJaLy+EvhGcPjEtr am4y3jvh3KGJSTMf1HHFIkrJqKq3qIlyxIM0EIVidMjVV6kJqK+9XaNbK+ciyyKSNz 0/lNivsSwhVFSMMidaIdtSJS4o5en5LR8Tsd7YVM= Date: Thu, 17 Feb 2022 19:55:41 +0100 From: Greg KH To: Baokun Li Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, oliver.sang@intel.com, beibei.si@intel.com, jannh@google.com, mszeredi@redhat.com, torvalds@linux-foundation.org, yukuai3@huawei.com Subject: Re: [PATCH 5.10] fget: clarify and improve __fget_files() implementation Message-ID: References: <20220215065107.3045023-1-libaokun1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220215065107.3045023-1-libaokun1@huawei.com> X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 15, 2022 at 02:51:07PM +0800, Baokun Li wrote: > From: Linus Torvalds > > commit e386dfc56f837da66d00a078e5314bc8382fab83 upstream. > > Commit 054aa8d439b9 ("fget: check that the fd still exists after getting > a ref to it") fixed a race with getting a reference to a file just as it > was being closed. It was a fairly minimal patch, and I didn't think > re-checking the file pointer lookup would be a measurable overhead, > since it was all right there and cached. > > But I was wrong, as pointed out by the kernel test robot. > > The 'poll2' case of the will-it-scale.per_thread_ops benchmark regressed > quite noticeably. Admittedly it seems to be a very artificial test: > doing "poll()" system calls on regular files in a very tight loop in > multiple threads. > > That means that basically all the time is spent just looking up file > descriptors without ever doing anything useful with them (not that doing > 'poll()' on a regular file is useful to begin with). And as a result it > shows the extra "re-check fd" cost as a sore thumb. > > Happily, the regression is fixable by just writing the code to loook up > the fd to be better and clearer. There's still a cost to verify the > file pointer, but now it's basically in the noise even for that > benchmark that does nothing else - and the code is more understandable > and has better comments too. > > [ Side note: this patch is also a classic case of one that looks very > messy with the default greedy Myers diff - it's much more legible with > either the patience of histogram diff algorithm ] > > Link: https://lore.kernel.org/lkml/20211210053743.GA36420@xsang-OptiPlex-9020/ > Link: https://lore.kernel.org/lkml/20211213083154.GA20853@linux.intel.com/ > Reported-by: kernel test robot > Tested-by: Carel Si > Cc: Jann Horn > Cc: Miklos Szeredi > Signed-off-by: Linus Torvalds > Signed-off-by: Baokun Li > --- > fs/file.c | 72 ++++++++++++++++++++++++++++++++++++++++++------------- > 1 file changed, 56 insertions(+), 16 deletions(-) Now queued up, thanks. Any chance you can do this for 5.4 and older kernels too? greg k-h