Message ID | 20231017011728.37508-1-ryncsn@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3829896vqb; Mon, 16 Oct 2023 18:18:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGiSKDoB9hxn5PBjs+N4EYexsJxpoLt5h3/XtZs1SUSEDwQgoW1Eiv1R80PvERJ2HlFbG/t X-Received: by 2002:a17:902:f154:b0:1bf:349f:b85c with SMTP id d20-20020a170902f15400b001bf349fb85cmr977745plb.1.1697505535773; Mon, 16 Oct 2023 18:18:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697505535; cv=none; d=google.com; s=arc-20160816; b=gBk6VhVAafahrvP0x1wbL8dmYzblO3A1dcNmHCrYs9hHMS/3BFB6oTX7Vx2B53g++V KMWYovFbljBOeaLG+EPq7WAdI4nGe27hpruQh0FNS4bUz+NwkefOiFXbvjfgOAWUdlQN 79BJlUh9Gmr16a3h1E1UibuXkc94CFokGFAfFuxlEDEth0es2AQgJuEDP6u4cnK/8ic4 nwjRX7J8308ZSAddKu3Mi3QGJ4fbza+Hd3RoVANAgBP7QeXvWA8C+7nl2ppdFPEo3DZK DrYqsOnwJuo1q4UUVaWfndqQjBsfnZcL2QIgYWc6tZc5uSTg51BVHUuHPp/pk7I7qEZi FHBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=8E2y54OTGlC4SszPQLmvr7ApnpGiyusAG53urqiJELY=; fh=BDoTlNTSMTtmfAhrHLAjD00kSeNPDu8bWtWc6vpRkQo=; b=CCss3fxHvee6wuGSKzwAaKf6w4M+q2+lkBNwIGVQUvGk/216QPBRf1SmJglUNkE8gz yM50gUQQfmPebzASr/scVUijPcKuJ8XPCsr0rIic7zawHcwzjVsI8f7lIz7x/ZZJYPgF 6VYT858C0e3P4CsimB4iHqxUdeFaIu5LYjUE7alnJN8JIMgaNk++zLJf+XOuq8qY3aqK EocGh0S8LCZigzAP+TeFquLWTO8z1lFyso6e/2ELVy/PHhjs6AzFIlWSXBXHzC3KEG8V nfa4i/TkYVtCcdT/dAV1LB0w7dYRg56bB4cg/noQI525L+OIuxmeZGgNDNXVOt2JroG3 oSPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=kMBcuqKy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id m16-20020a170902db1000b001c4660cd474si613784plx.634.2023.10.16.18.18.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 18:18:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=kMBcuqKy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id CCA26804284E; Mon, 16 Oct 2023 18:18:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232577AbjJQBSo (ORCPT <rfc822;hjfbswb@gmail.com> + 18 others); Mon, 16 Oct 2023 21:18:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232096AbjJQBSm (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 16 Oct 2023 21:18:42 -0400 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9717CA2 for <linux-kernel@vger.kernel.org>; Mon, 16 Oct 2023 18:18:41 -0700 (PDT) Received: by mail-ot1-x331.google.com with SMTP id 46e09a7af769-6c4c594c0eeso3509723a34.0 for <linux-kernel@vger.kernel.org>; Mon, 16 Oct 2023 18:18:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697505521; x=1698110321; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=8E2y54OTGlC4SszPQLmvr7ApnpGiyusAG53urqiJELY=; b=kMBcuqKynKKuLmAtvC1tF38zG1aD+steiWji/p7L5tduX+na25iP+vv2I9L9RArLhd bAfiGGI78B4Gmv0onPqU/Ho6g5BR0aJTNVdKYYuoNAepxBMmzExz9zp1d5tPLRLuG10P 6iGyvpFcz1zMJM9oSGaRBgW+gA4IPXmhXlLv6Nv7LIEKBrDXRV8oI0mvIZ92rd8LjwuS mLR/DLJMcFjoHOXhLHGaHopJ3E6K8xA1H4+k+tH6QTHNmEzt7xyIKPuUHw4lhAIwth3A ULt50qi7b6Aq4VOXrVJ7HTinQx2h/A8aRnOr+q78lfK1fZt1ekqcYgH8rs2x9D5OxIiQ /vzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697505521; x=1698110321; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=8E2y54OTGlC4SszPQLmvr7ApnpGiyusAG53urqiJELY=; b=FIOo1rYu/t7cfz9zp+JrTqu+Lsh6+H4Sk7bOkyLzor9aiYi/HUTlygHpljFx7OlVFG RqoIah37BzptrfHuHgNa2dXj+TgvzuMEhFZlwQLYEP9VrZniRo/JGfixpAcEy93p/vjI r/Y7R9dW+bxUBaJlkxL7WG34p9f0AerH4NhjjwTdMHmJezaZmpqUXL7RNnPWkyYBfeZI 7n4hKQcugjW7r5Uo7oYAPYKZpzZCjnpSsrvPYBagy+m8SQ6SwukWL1c8ZeJhxbFkgatL 9Z257dMKgeYvgA/MgQAneCl2mJtU5pLrZV51Tjq62fwMPHyyhb20HS3FW0ew83gv1CWK t8xQ== X-Gm-Message-State: AOJu0Yz0qHAfkGHfhjOTpY2h5OT/Kjn5QoFHmlOycm+Cjta9YSz3tes7 hlhF13/JzVXss7DgDjszEAv5ibJcQmLBk69O X-Received: by 2002:a05:6830:1e72:b0:6c4:e81f:59b8 with SMTP id m18-20020a0568301e7200b006c4e81f59b8mr851723otr.22.1697505520861; Mon, 16 Oct 2023 18:18:40 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([103.7.29.31]) by smtp.gmail.com with ESMTPSA id y15-20020aa79aef000000b006926506de1csm191839pfp.28.2023.10.16.18.18.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 16 Oct 2023 18:18:40 -0700 (PDT) From: Kairui Song <ryncsn@gmail.com> To: linux-mm@kvack.org Cc: Andrew Morton <akpm@linux-foundation.org>, "Huang, Ying" <ying.huang@intel.com>, linux-kernel@vger.kernel.org, Kairui Song <kasong@tencent.com> Subject: [PATCH] mm/swap: avoid a xa load for swapout path Date: Tue, 17 Oct 2023 09:17:28 +0800 Message-ID: <20231017011728.37508-1-ryncsn@gmail.com> X-Mailer: git-send-email 2.42.0 Reply-To: Kairui Song <kasong@tencent.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 16 Oct 2023 18:18:53 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779963564443307889 X-GMAIL-MSGID: 1779963564443307889 |
Series |
mm/swap: avoid a xa load for swapout path
|
|
Commit Message
Kairui Song
Oct. 17, 2023, 1:17 a.m. UTC
From: Kairui Song <kasong@tencent.com> A variable is never used for swapout path (shadowp is NULL) and compiler is unable to optimize out the unneeded load since it's a function call. Signed-off-by: Kairui Song <kasong@tencent.com> --- mm/swap_state.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Comments
On Tue, Oct 17, 2023 at 09:17:28AM +0800, Kairui Song wrote: > From: Kairui Song <kasong@tencent.com> > > A variable is never used for swapout path (shadowp is NULL) and compiler > is unable to optimize out the unneeded load since it's a function call. > > Signed-off-by: Kairui Song <kasong@tencent.com> Reviewed-by: Matthew Wilcox (Oracle) Possibly worth adding a reference to 3852f6768ede ("mm/swapcache: support to handle the shadow entries") Not sure it's worth a Fixes:, but that's where it was introduced.
diff --git a/mm/swap_state.c b/mm/swap_state.c index b3b14bd0dd64..ab79ffb71736 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -109,9 +109,9 @@ int add_to_swap_cache(struct folio *folio, swp_entry_t entry, goto unlock; for (i = 0; i < nr; i++) { VM_BUG_ON_FOLIO(xas.xa_index != idx + i, folio); - old = xas_load(&xas); - if (xa_is_value(old)) { - if (shadowp) + if (shadowp) { + old = xas_load(&xas); + if (xa_is_value(old)) *shadowp = old; } xas_store(&xas, folio);