From patchwork Tue Oct 17 01:17:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13424281 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DEB6CDB465 for ; Tue, 17 Oct 2023 01:18:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 92FB78D00E0; Mon, 16 Oct 2023 21:18:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E9878D00DE; Mon, 16 Oct 2023 21:18:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7CE4E8D00E0; Mon, 16 Oct 2023 21:18:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 6D9BA8D00DE for ; Mon, 16 Oct 2023 21:18:44 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1FFBA160CDE for ; Tue, 17 Oct 2023 01:18:44 +0000 (UTC) X-FDA: 81353193768.19.38345BC Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) by imf02.hostedemail.com (Postfix) with ESMTP id 65EC080005 for ; Tue, 17 Oct 2023 01:18:42 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=C3o5Ojq2; spf=pass (imf02.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.210.52 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697505522; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=8E2y54OTGlC4SszPQLmvr7ApnpGiyusAG53urqiJELY=; b=Ag2mTWOw+0zC0MDzlqWEYPcTO0POFMSV+9bEWpwQr2qRVNJe6fhk53ybWUzo6mgCDqcqHv VscNLknMTJhSYh3LmmODT4G9LiiVyUjnGxXURKW7XyakrtOtWacx+erZNeNqgMsnCwW9ZZ 8RatkkD61J8VIOckIHjgt0oO4om15bk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697505522; a=rsa-sha256; cv=none; b=bWwstN7ETfK4aDc0ik3NNEVY3yy6lkNyk0WbcIjazOqSmVHUp34pDTnNrXASrUmfaBuB11 c/fa5b0Svmby87Wq9BO+U5qs2m4wTR4MRdBmhJPRV9u+9gHNU13eEk1rrYb6y9ejpkC0mw zwAlbbC+yDVJJiAfIAGwy4+0MGFcNDo= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=C3o5Ojq2; spf=pass (imf02.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.210.52 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-6c7bbfb7a73so3492935a34.3 for ; Mon, 16 Oct 2023 18:18:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697505521; x=1698110321; darn=kvack.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=C3o5Ojq2ovh++6K+Y6VZdhBeM89v5UzSJ6ZBbaYQBnvbUyFtX3lkq9+uIAQWPtTxRQ NTUMr5f2x/Vn87V2nxiNubzExffF+dkwvnCXezKmqb72IKtcNiB5rydlStJq8hoJgyDx F6KvzRFNcIXSahTAH2cDiFNQiJL1flZ1ENPciDVzUa2cv62ynKHEHd2+Yb+dThlFO++h 1t4T2NBJVT63M6GqpLB1Q+ddSAvmZ0qWyc4ZK0aviTANrog0Xx/w/bO6V/HLjzo6I/mx 6VahRRCIwhLqEORt5vhRZfiUHM1wgy8sTcyDeuNeGhi3plB1NZQZuQ3jFouo9rvrM6m+ wsMA== 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=oEsAzwy+MWr46exVuElSsGUWNnDA32Dtfg1CEDdj6NNk2ULITj0nrsEOCQ7axAvInz WOhg92Jvna7F0LKgSLApa/ShqN/rjLjkmrB/6X3dJFYVv3IwP3pZaagzRUaA9G8KIMi2 ykyso5/J+/IyHqXGYeyk2hi7MntGDGP+kjixpEZjwWm+Sja1l2aBvCk+NNkcPRx/7kS+ BIbPKBrVUFO/KQ/F8fH4dsx7SglrPy4Ptyk7oLcqSXvHao4VwXuye/OgS+oAbfarXpPY UX2pJFFiG7hHz2Kr9CsEc3CUbMl5jNhX5r2kh1+2Q7e+35SIYgM9RAMy+uDlt8F6nBRO lV8g== X-Gm-Message-State: AOJu0YyCcX5rLWsMHXQitRQne2YjktfnypwvgYlBIwhk9FoA1YiJ6FAO KtrDRc3fSAn8YTgqPkVpCN3qMNkuE/dyPUIW X-Google-Smtp-Source: AGHT+IH6NELBiIY7B0GJ4SFGNnXeKXcRCm9FRmr4KcEHGyr1Vn29uHDiZ6a7F8PJs3exhbdJrhL7zA== 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 X-Rspamd-Queue-Id: 65EC080005 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: zce9xebqai3ddfaipy99dp9rsey5euzt X-HE-Tag: 1697505522-535055 X-HE-Meta: U2FsdGVkX18ss9VvAjOtElldgRVO0cXT9gDpNusSZZ/FOjk065bFIujL9AwATpWsZ5n3MTdTDvIAk5OPUyiHuto2j6in9/gSWGi+d0/IxBeWAXhQCivGh/l9OeoUD8mvQ2o2gq33eBogcxkYK4BABIc6xQpEebwxVFruH/gwO7h5Ip+TkDLXB6QAmW7y07sRyEMnOfUJzJ2shmoLNv8AX+riPgIDlnNgUqJ26oNTmB2TJT5lep2ohETolLrzx6PjEQLub+03WpU5cD7m0h4eJuBkS2JP5XDe0FlmS7BcifPkYRYbwKVp6wSmcDabn1tzvdxJeLUlUb4rJ/q2YWFEZUYqT1YG8uTQ90rSkXG+BvBXmn+rfnehJ7RU8WT2TX9SMKBovZ8cyugUhWsTfoWP30hnHB2lua7AkmdXPVq2NLWmIhcvjMoQXQypqWz1zWA5As0qt8vgwp+JI1c5JkW5HPmX9OPOG3UQjmKpQBbPVKDh1pRV/ngd25pbYtS0y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G54uYhOuTcdcLch5Hf++x3dP6Wqm+8FUdcZSHmLB13EFA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000006, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Reviewed-by: Matthew Wilcox (Oracle) --- 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);