From mboxrd@z Thu Jan 1 00:00:00 1970 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 9457AC43334 for ; Fri, 17 Jun 2022 17:50:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A814D6B0074; Fri, 17 Jun 2022 13:50:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 76C376B0080; Fri, 17 Jun 2022 13:50:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34D726B0085; Fri, 17 Jun 2022 13:50:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 876DF6B0071 for ; Fri, 17 Jun 2022 13:50:26 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 5E034806A7 for ; Fri, 17 Jun 2022 17:50:26 +0000 (UTC) X-FDA: 79588467252.22.2460BDB Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf15.hostedemail.com (Postfix) with ESMTP id 08288A0083 for ; Fri, 17 Jun 2022 17:50:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=/zYcb5obGONvibUxmNa4Tqkoa6GD9PKM1MXtj+UbzY8=; b=eP03SA3vpJC/Y5Yvp909DXZgbt Qe2/nsHtkU18RP71Rli3aStq5DW/BnNkkzaDZKvI0IRzrVbQIE5f/RdPVLt3EZg+rkTUM5egapo0q tVck12lMgKpU8UpwMO7qknWJddSAqE1bFnK1N2pXjD15SjcSTFRHu562zTQ+t5da8e1rlS+IzgP9S olfZQAhwn3rEAz+BdDHywVzx5DXhYzF6p58JXudsk9O13MR/1zMdG0uizjPGTau16yHrL3qOO/uTm B7ZNW1OK2c3NPXYmLTB+9CIvYlbYIuRK/XMkMcn2dy6PB4Wq/wHK97QqFBNkC44HbnTpe2uXECWoX O3JjUWyA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1o2G6y-0030ab-I6; Fri, 17 Jun 2022 17:50:24 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 11/22] mm/swap: Optimise lru_add_drain_cpu() Date: Fri, 17 Jun 2022 18:50:09 +0100 Message-Id: <20220617175020.717127-12-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220617175020.717127-1-willy@infradead.org> References: <20220617175020.717127-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655488226; a=rsa-sha256; cv=none; b=sxNF4Mhl4iU/XbTIQbAn8lSTkyIF0Ewpix4S+R5s06So3eicljioh1Ez2A/ddxhhPYWu11 XNqv2pbyGfFp7Tc1ssj0p6VbFD/Q6oBHQaY/6pkcrObEbc/12P6vjhuaxuGh46kLiDWRe1 d4I62wsXTmQHC6IZfZ+Nz+W50+eFzIw= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=eP03SA3v; dmarc=none; spf=none (imf15.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655488226; h=from:from:sender: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:in-reply-to:references:references:dkim-signature; bh=/zYcb5obGONvibUxmNa4Tqkoa6GD9PKM1MXtj+UbzY8=; b=0zMjffQWO9rcpxLIUTkleMzW3A0dKDvFU6UYDb0Expt0uVAF3nHmwsP+o33rKQ1n9JdVIF 0Wmx0bPMPJbP9tFc2lk6yYuY4yq6WqYoHEI511evrLGT2794eJIYAbK2x3HajsRQu3VyHk y25jETJUbIQcsop49qu/PzwI6thY5S8= Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=eP03SA3v; dmarc=none; spf=none (imf15.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspam-User: X-Stat-Signature: yh1ugajmnk6cgoq99cxq74iozxqdms18 X-Rspamd-Queue-Id: 08288A0083 X-Rspamd-Server: rspam08 X-HE-Tag: 1655488225-807732 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Do the per-cpu dereferencing of the fbatches once which saves 14 bytes of text and several percpu relocations. Signed-off-by: Matthew Wilcox (Oracle) --- mm/swap.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index 7966aa6bdd3f..5ea6ae795f0d 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -620,7 +620,8 @@ static void lru_lazyfree_fn(struct lruvec *lruvec, struct folio *folio) */ void lru_add_drain_cpu(int cpu) { - struct folio_batch *fbatch = &per_cpu(cpu_fbatches.lru_add, cpu); + struct cpu_fbatches *fbatches = &per_cpu(cpu_fbatches, cpu); + struct folio_batch *fbatch = &fbatches->lru_add; if (folio_batch_count(fbatch)) folio_batch_move_lru(fbatch, lru_add_fn); @@ -636,15 +637,15 @@ void lru_add_drain_cpu(int cpu) local_unlock_irqrestore(&lru_rotate.lock, flags); } - fbatch = &per_cpu(cpu_fbatches.lru_deactivate_file, cpu); + fbatch = &fbatches->lru_deactivate_file; if (folio_batch_count(fbatch)) folio_batch_move_lru(fbatch, lru_deactivate_file_fn); - fbatch = &per_cpu(cpu_fbatches.lru_deactivate, cpu); + fbatch = &fbatches->lru_deactivate; if (folio_batch_count(fbatch)) folio_batch_move_lru(fbatch, lru_deactivate_fn); - fbatch = &per_cpu(cpu_fbatches.lru_lazyfree, cpu); + fbatch = &fbatches->lru_lazyfree; if (folio_batch_count(fbatch)) folio_batch_move_lru(fbatch, lru_lazyfree_fn); -- 2.35.1