Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2861439rdg; Mon, 16 Oct 2023 18:18:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHM6RKaK052Ih0O4SCRQcC41xZC650XAXEw837KQhjTV/zmY4ieRwaPEFbJATw5TzEI9Y0j X-Received: by 2002:a05:6870:b025:b0:1bf:9f6:b810 with SMTP id y37-20020a056870b02500b001bf09f6b810mr861946oae.36.1697505533595; Mon, 16 Oct 2023 18:18:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697505533; cv=none; d=google.com; s=arc-20160816; b=GsSYTY6tK7is482lXa6g1BBty/HiiGkURtmShIty7ih+8rLvbgCH4vRey0qurXdg1H eE4RAqSASYzsQzAFsDco8JDUPIU9NLAdbOeRqxy4INvXT/p4qqaxGwqBv3zgs5fdWN6g 8UEQFrnyba3NI6qJ1W2fzwvtrQXRF0S+RqlnOovifJovUkWoXqfDgrk/DxH9RVAlnSQM HazOrnlxZQn4hc/j4vtYudxCgWEJYgkJ72qmOQjnfYF099YJ40E2mZK2LV0qgmm7TANV jIKC9YZ9zS2TXVDcPSginFTfUGBOVZDF59YbG/VZvcxHv84dSXeDTFQVFuyVbNdNOoqU xIpA== 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.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id j186-20020a638bc3000000b0056a36ac322fsi575097pge.514.2023.10.16.18.18.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 18:18:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; 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.35 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 groat.vger.email (Postfix) with ESMTP id 5EA028052BED; Mon, 16 Oct 2023 18:18:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232457AbjJQBSo (ORCPT + 99 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 ); 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 ; Mon, 16 Oct 2023 18:18:41 -0700 (PDT) Received: by mail-ot1-x331.google.com with SMTP id 46e09a7af769-6c4c594c0eeso3509723a34.0 for ; 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 To: linux-mm@kvack.org Cc: Andrew Morton , "Huang, Ying" , linux-kernel@vger.kernel.org, Kairui Song 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 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 groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 16 Oct 2023 18:18:51 -0700 (PDT) From: Kairui Song 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 --- mm/swap_state.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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); -- 2.42.0