Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp916481lqs; Fri, 14 Jun 2024 09:10:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUOESJC9CEZG2MtdxoY6dvVmUCxYQUL/hHG8Euldxq2KBD964eevg3Wpc4vFc9wUgscdMh2m9l72r/ayZA4nlgr6q66KJRAfhUsvbVjbw== X-Google-Smtp-Source: AGHT+IEbxW4SrorDMrrbsfRegHraPlq4b0v3Ty9F9rSIcRIwz1OWRx83jCqrngWY3HyVAlxBcoHd X-Received: by 2002:a19:4317:0:b0:52b:e7ff:32b with SMTP id 2adb3069b0e04-52ca6e67557mr2305132e87.23.1718381417768; Fri, 14 Jun 2024 09:10:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718381417; cv=pass; d=google.com; s=arc-20160816; b=luOCf5F9QEwcF3za+0qEESCluy7tCt6CXTtPU2TeHuHqInAsY+5/kw4hrJOBzaHZbw QAxLthx4SgUf40WqtnRpM1bHhr5nKOqDJsfwfDWBSY5PqkZqiNuOw4kRh4lZbVddg49b LkxPwB35h7wgDKJYBo5ifoq9repD4oZROe5cKDeXir1+fT9BpA1xSZhWGAUbh8tSDtuI dTi2xJC3d4woWiWXhI33BcOJWt6jmnEiQLG/MLOBCpGq4l0aOKV1SGfmuyKheQJrYQNg 3eaNBqUrQNPIFAifBzZfMSikiM6m2BGwh5maJ1cyQljCguGilawhdAWosKGat9DpW8lz SrlA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Ju/v/06OevPOjeMfWqNHpcGL24NpOq/cnw69V7OV0+M=; fh=g8QqGHOWWm4utLeC66qTu1fvtAi2WK8UyNYLFnjVwKI=; b=zlRlcv5wACLOyW4apW+N8jiB06i92MiN2yksw4zBMFmprcCv0MSjw4SanTg/sApYRl g0JJy9nxdLoqL/om6Z4nwhArQhhrvjJsQgjeQtN7BKc2PgRcodNVW77ohKc+u+ZR4awC VS29eCar88BzCy4HZQ1prgR3OkRIanKh0SyXHKk3rQ6C2qmwMra2U9ouZ0knEAzbt+jN BzNrQqq2YKmf3mL0+LVmBMul16h1oQdmijEHX3qGYiGU2Ys9NTHyj2TWrY1g6A5nQW5n iE2wQW+l+f8VKIFq8Tn3/WqLkGR6f9DNDEOq4ucTPp95wJWtUrUosLrrNjWAXRf7ABIZ TMlA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Il5nuDff; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-215203-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215203-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f56d21ab2si180906466b.85.2024.06.14.09.10.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 09:10:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215203-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Il5nuDff; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-215203-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215203-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 79A011F21C7A for ; Fri, 14 Jun 2024 16:10:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2BD7519CCE8; Fri, 14 Jun 2024 16:09:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Il5nuDff" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4EC819AD6E; Fri, 14 Jun 2024 16:08:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718381339; cv=none; b=lEp3rb6cOKV8KrkFCaWj/OhBn4XDJ8xdRnQXsoJLyS+tQBVM3RQREW+J+nHpxH/o4SQRg87+qE8yxf6KkXNwdTebU2LaCjSDuJeuiKwaldSjogcm8hpyELBDPi+cgQQXyqD5/hWj1V8c9s3IJVJWjK1tj5zzHNywQroEXIZVt90= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718381339; c=relaxed/simple; bh=XaUtWTN7akwimeRKOM+4b5jvaenMH+iXA0eNBgjkAJY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TH7WvgUpMaFD2zowYVNGknQGageRt2i75rvjdj0UUpcV9XvLHZkj+ZeCmLuYx50O1vGeVbDZzP1B+nQ/Cjhar7peJC2D9C6LR8vPDKOafSI1mxOc3sOhsNXy442zCczrN3uznf9SQvDBLpotJUKRyvwMaCz69ej6lFS0wn2zMSY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Il5nuDff; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718381338; x=1749917338; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XaUtWTN7akwimeRKOM+4b5jvaenMH+iXA0eNBgjkAJY=; b=Il5nuDffywf1zmXUqc97i3BH98Sz2p21XhFEgtWWtifNVtiVTHU0sVJf tAg4FhK76rOsgKpecTB8qC+0DbMmWWPDMzUkZrVh5bZQ0zaSUojxRdWJ4 GZoMuj+nzNG39GYrNT3YdidoxoCmQv/nfLEC3sBJgkWwyPN0VyPB9AvMw 6DByBWWfkt2rS1dbyDjI8iU5zK09/BtGkvQ3qa4DDim8j7mA+WJnYMKbf ZTq89O/wVVqbeBholrdtib2JtOLFfzR+XT/DoKeSaNMY1l5v609fHUQhm omtItsIV8/hlE/4pH8pAI78BdG6B2M34jw5hJUFQoQ3crwdHBkyNGDmp0 A==; X-CSE-ConnectionGUID: znlBW63ET6qbgtpN1RE4mQ== X-CSE-MsgGUID: 06Lb98oZSOeM4xpccqAzlg== X-IronPort-AV: E=McAfee;i="6700,10204,11103"; a="15399411" X-IronPort-AV: E=Sophos;i="6.08,238,1712646000"; d="scan'208";a="15399411" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2024 09:08:57 -0700 X-CSE-ConnectionGUID: P7B4ZEOATw64b2ByqlQHlw== X-CSE-MsgGUID: VuUBpHm/SE2pOap1LEEH3g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,238,1712646000"; d="scan'208";a="71741079" Received: from linux-pnp-server-16.sh.intel.com ([10.239.177.152]) by fmviesa001.fm.intel.com with ESMTP; 14 Jun 2024 09:08:55 -0700 From: Yu Ma To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, tim.c.chen@linux.intel.com, tim.c.chen@intel.com, pan.deng@intel.com, tianyou.li@intel.com, yu.ma@intel.com Subject: [PATCH 2/3] fs/file.c: conditionally clear full_fds Date: Fri, 14 Jun 2024 12:34:15 -0400 Message-ID: <20240614163416.728752-3-yu.ma@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240614163416.728752-1-yu.ma@intel.com> References: <20240614163416.728752-1-yu.ma@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 64 bits in open_fds are mapped to a common bit in full_fds_bits. It is very likely that a bit in full_fds_bits has been cleared before in __clear_open_fds()'s operation. Check the clear bit in full_fds_bits before clearing to avoid unnecessary write and cache bouncing. See commit fc90888d07b8 ("vfs: conditionally clear close-on-exec flag") for a similar optimization. Together with patch 1, they improves pts/blogbench-1.1.0 read for 28%, and write for 14% on Intel ICX 160 cores configuration with v6.8-rc6. Reviewed-by: Tim Chen Signed-off-by: Yu Ma --- fs/file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/file.c b/fs/file.c index e8d2f9ef7fd1..a0e94a178c0b 100644 --- a/fs/file.c +++ b/fs/file.c @@ -268,7 +268,9 @@ static inline void __set_open_fd(unsigned int fd, struct fdtable *fdt) static inline void __clear_open_fd(unsigned int fd, struct fdtable *fdt) { __clear_bit(fd, fdt->open_fds); - __clear_bit(fd / BITS_PER_LONG, fdt->full_fds_bits); + fd /= BITS_PER_LONG; + if (test_bit(fd, fdt->full_fds_bits)) + __clear_bit(fd, fdt->full_fds_bits); } static unsigned int count_open_files(struct fdtable *fdt) -- 2.43.0