Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp889009pxb; Thu, 17 Feb 2022 17:38:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJyzr75qZknsv7RyQ28YpNQZZJ8lQzN21fn0tI9GvIPOK5bPxi+3y/wDouGmBopODVourGpA X-Received: by 2002:a17:90b:f0c:b0:1b9:c6b7:7cd6 with SMTP id br12-20020a17090b0f0c00b001b9c6b77cd6mr10010169pjb.231.1645148317968; Thu, 17 Feb 2022 17:38:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645148317; cv=none; d=google.com; s=arc-20160816; b=vA6KBzai6Re00/lckjTGmJPJqrvYYkOlGya7nixTgctAT4dGZfWZOpw8fRIxBfDdaq iXIks0G8+d7c30U9IhX2SF6OvnOBNC1/39HOn2BBLp0s3Rio3g+XYyT+lOuyydvtE0WQ mwFkv8ZR6fY7kxLGdU0zNjC2qIOVzKOFw5sHQOsBB+7BRwTpberPRhdJobIo59lcLT1k ibeZ+PYcxDYjB79R0Z6beAzwzIVTxRZk9HkVm4afJhv/ewey0ZYK8iK+rY2vnVE51ZVl yEssykrc+u44uGfKF2kXxYLsQtf3R8TWT16WVpKagfz1sUEh5tVb8idJHyU4xFgw9LTI TODg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=+eXLKleIgWeIb9fg8YOJNnQQJ47t5d/guIfAPOnP+DI=; b=KG7wsCEp89+L9oTR5EiyxALI25m9N9HP1Uubwvz24d94HuMLq/3SiGQ59Yr7MA+Myg llIf8gWaudZRxXQ+3L55zgiBKR91FCywu22KjS81e9V6VH3/spkY1HBpjjxKGqVFQaw+ 2r1DP3TgnALw6l+VMoqLFTBhl0LsiQrpUvMjh6t1wkymKgmi1HpSoJplHqJswxgVnCLg TO7IPTI9bmtPdw4L5isi9yWzfS0sfICi/chPmhnYwEBVS2etRQnORPjt/9APaCyPf8rn wJnhP64P+QYtQGvDyenUIxxQPL1LWurT6D5tLwJhX+fME8QZ4bIMsnx5eKSLAkOchQD0 1o7g== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 65si1125940pff.216.2022.02.17.17.38.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 17:38:37 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C7A36366A1; Thu, 17 Feb 2022 17:28:03 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231249AbiBRB2L (ORCPT + 99 others); Thu, 17 Feb 2022 20:28:11 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:36370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231230AbiBRB2J (ORCPT ); Thu, 17 Feb 2022 20:28:09 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7887C2BB09; Thu, 17 Feb 2022 17:27:52 -0800 (PST) Received: from dggpeml500020.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4K0DYH5GNrz9sm9; Fri, 18 Feb 2022 09:26:11 +0800 (CST) Received: from [10.174.177.174] (10.174.177.174) by dggpeml500020.china.huawei.com (7.185.36.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Fri, 18 Feb 2022 09:27:50 +0800 Subject: Re: [PATCH 5.10] fget: clarify and improve __fget_files() implementation To: Greg KH CC: , , , , , , , , Baokun Li References: <20220215065107.3045023-1-libaokun1@huawei.com> From: "libaokun (A)" Message-ID: Date: Fri, 18 Feb 2022 09:27:38 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.177.174] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500020.china.huawei.com (7.185.36.88) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 在 2022/2/18 2:55, Greg KH 写道: > 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. Thanks! > > Any chance you can do this for 5.4 and older kernels too? It's my pleasure. I'll sync this patch to 5.4, 4.19, 4.14, 4.9, 4.4. > > greg k-h > . -- With Best Regards, Baokun Li .