From patchwork Fri Jul 14 11:47:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13312902 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 771C0EB64DA for ; Fri, 14 Jul 2023 03:47:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF528900018; Thu, 13 Jul 2023 23:47:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DA50C900002; Thu, 13 Jul 2023 23:47:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C9424900018; Thu, 13 Jul 2023 23:47:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id BABF7900002 for ; Thu, 13 Jul 2023 23:47:19 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 87D481C89F3 for ; Fri, 14 Jul 2023 03:47:19 +0000 (UTC) X-FDA: 81008832198.14.B6DE11E Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by imf01.hostedemail.com (Postfix) with ESMTP id 1071640005 for ; Fri, 14 Jul 2023 03:47:15 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; spf=none (imf01.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.51) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689306436; 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; bh=315iybBJ6fMjnDRV9a8J/EZ4Zb1HUNpFnwxRjwE4fmY=; b=mt/S2GPwLNGGi6mmWY/+ShRHpNVWQ1caTRUMcAIjzm4Ksv51NyRhBWpeQjKikCDwYLrR7s eZ58nbeyOIEQ0+4pAXANbSDpYg2+PdUA5wlQFMrOr+HGsXQbboYmC+jz9ntTv0ZjeCkxKc pG9azbLJqtW5J3MTvl64XAZWrkeSWuY= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; spf=none (imf01.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.51) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689306436; a=rsa-sha256; cv=none; b=0t93+uEgeLIpVBVNXappPHuTcVEWqJWQrvk8gp+kdDnqtmIfXNarz9UMuERLpkuAVgoLfb UzjV5RV7AGGpInHqGWKGiwnheXIujvvLdDtupeArDTomhtmyUcd/d5tBE5rhVUo+ah99c+ K2F57CBKBO0WzWPeRGa/xrv70YwKoGA= Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4R2HV53PRCz4f3nJN for ; Fri, 14 Jul 2023 11:47:09 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP4 (Coremail) with SMTP id gCh0CgBnTbE8xbBk4HW0Nw--.17751S5; Fri, 14 Jul 2023 11:47:10 +0800 (CST) From: Kemeng Shi To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: shikemeng@huaweicloud.com Subject: [PATCH 3/3] mm/page_ext: move functions around for minor cleanups to page_ext Date: Fri, 14 Jul 2023 19:47:49 +0800 Message-Id: <20230714114749.1743032-4-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230714114749.1743032-1-shikemeng@huaweicloud.com> References: <20230714114749.1743032-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgBnTbE8xbBk4HW0Nw--.17751S5 X-Coremail-Antispam: 1UD129KBjvJXoWxWrWkJF4xJw47Aw13Zr45Awb_yoW5KFyfpr 1akw17tw15J3Wagwn7Ja1kCr15Grn5G3y7Jr17Kw1Fv3WYkr40gry7Kr90vryvgrW8Xry5 Xr4ktr1qk3WkJaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPSb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M2 8IrcIa0xkI8VA2jI8067AKxVWUWwA2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK 0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4 x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l 84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I 8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AK xVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zV CS5cI20VAGYxC7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E 5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAV WUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY 1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI 0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7s RNBT5UUUUUU== X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 1071640005 X-Rspam-User: X-Stat-Signature: n51fbt151a43trs6mhpcnei7oa6c1jn5 X-Rspamd-Server: rspam01 X-HE-Tag: 1689306435-864316 X-HE-Meta: U2FsdGVkX18WDf3a2/xoUuxiSyR7Lhtq7LUYMZKox7uzX2I6k6ZgO9ZDxrLsTc8N7Ec510F0QWtjBdd9w0yI+QbLCs/iS4FvKFJ48x4uWIGgWrvwv5DydHOg9jBd2T+lWKXayYDuOgwiYU9CqQ3oGY3pk+L7GFWoYbZKE+vQa7YAV5Gvm4sBKI0Gz59A4qs3CwtRCdASCBlyK0JkIy66UczKO4TCe95Ij1GoomQT5gZ3kkE5hgXkgs2xNAIGzrdT9q1m8UcwenTDkjdM2LRq/3ZMgmU6DW0oqJg73SrVd0EPOsXdFiHpUGWzASTkS1D79u+Xk8l5aepNreDN/z578ghNkl5H95ZlleNVggtSrZQowt+J0ehnRQS7oXYOgMaOfw94qfwXXqriawk8HdRYzBR/cRx85obNduSOg613da5IICFUH7yZg9/Ugtin0DHtosJceYyQba27GA8CLIOYDJWZ2R6VumE/a+fz4k3du4JtOgwia+CSJQP+AUJ7nswVHthOcTW47390Y/nsBauGi2jFQce3N2/01ALfh7nEnzZvrMG9sjQHWvyVK3+itsAk+bgFdKUJhPOK38zXHZzQCkg25XUbBzgpvFYwEOQTabSSffzAiULUOeiSk1FJY2eyQxhnGjBEzwHfBIFK7oTCR1BdFi0ltyJXuuhXMyWFZQEXyO+YUxHNKzGGUlIBl216cz5wbYGOpe+ry8LtPDDrkrYxPaunT7uiOM0NOTX5t7Gcd+vCfQ+vKGInos4dyNCcU1KwK27vDXvoV6VcyrX2pEKh3fzyuPUU2wKuvVZJcDXIZD61HTSkHa1HqfETZq2t3Fo6qlyTCIneebSU3066tkT+nu+FEs3SfcAe0J+3/qSSZCiP1i6yQCgdOL1V4jdYffZrBb1mnzQnTcaoW4FnfywdiZC5T+K+kLbu0iuY6GPLzaKoFERhVB31VvVQMPfLvQNTEffsrJqGWHB8TtL gQEFDAn3 aYzO5x6TT/qRGdOPAgR9V2sek58Hm68s7VNn3R5pecIUsRss9JhXP2SPIRMNrzjTdqvOPAv5dkgZnVQIDKZAtYdQG5MlNstQ0dA6dxf+0GRwm8JR4wY4zgoh2gGJTDc85oVVw5Y4S2vICXDBxJH1BekWI+L9tYpGkQW0XbyWzplrfmFOkZUSDhO11nebZVkIE8WZM7w8PN478d2SaPmOTh2a24r5rBZL9YOFiLdwMaAaAx0ABTlsG3kFN8GeaL3bnTMS/CNpa2MtIna+Po5t+eHNsCStT7o++wJpqwNrcIzkv7LKzhyE0QJBkgpPOdrNGIcgv 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: 1. move page_ext_get and page_ext_put down to remove forward declaration of lookup_page_ext. 2. move page_ext_init_flatmem_late down to existing non SPARS block to remove a new non SPARS block and to keep code for non SPARS tight. Signed-off-by: Kemeng Shi --- mm/page_ext.c | 96 ++++++++++++++++++++++++--------------------------- 1 file changed, 46 insertions(+), 50 deletions(-) diff --git a/mm/page_ext.c b/mm/page_ext.c index f052397dc70f..4548fcc66d74 100644 --- a/mm/page_ext.c +++ b/mm/page_ext.c @@ -90,7 +90,6 @@ static struct page_ext_operations *page_ext_ops[] __initdata = { unsigned long page_ext_size; static unsigned long total_usage; -static struct page_ext *lookup_page_ext(const struct page *page); bool early_page_ext __meminitdata; static int __init setup_early_page_ext(char *str) @@ -137,62 +136,16 @@ static void __init invoke_init_callbacks(void) } } -#ifndef CONFIG_SPARSEMEM -void __init page_ext_init_flatmem_late(void) -{ - invoke_init_callbacks(); -} -#endif - static inline struct page_ext *get_entry(void *base, unsigned long index) { return base + page_ext_size * index; } -/** - * page_ext_get() - Get the extended information for a page. - * @page: The page we're interested in. - * - * Ensures that the page_ext will remain valid until page_ext_put() - * is called. - * - * Return: NULL if no page_ext exists for this page. - * Context: Any context. Caller may not sleep until they have called - * page_ext_put(). - */ -struct page_ext *page_ext_get(struct page *page) -{ - struct page_ext *page_ext; - - rcu_read_lock(); - page_ext = lookup_page_ext(page); - if (!page_ext) { - rcu_read_unlock(); - return NULL; - } - - return page_ext; -} - -/** - * page_ext_put() - Working with page extended information is done. - * @page_ext: Page extended information received from page_ext_get(). - * - * The page extended information of the page may not be valid after this - * function is called. - * - * Return: None. - * Context: Any context with corresponding page_ext_get() is called. - */ -void page_ext_put(struct page_ext *page_ext) +#ifndef CONFIG_SPARSEMEM +void __init page_ext_init_flatmem_late(void) { - if (unlikely(!page_ext)) - return; - - rcu_read_unlock(); + invoke_init_callbacks(); } -#ifndef CONFIG_SPARSEMEM - void __meminit pgdat_page_ext_init(struct pglist_data *pgdat) { @@ -536,3 +489,46 @@ void __meminit pgdat_page_ext_init(struct pglist_data *pgdat) } #endif + +/** + * page_ext_get() - Get the extended information for a page. + * @page: The page we're interested in. + * + * Ensures that the page_ext will remain valid until page_ext_put() + * is called. + * + * Return: NULL if no page_ext exists for this page. + * Context: Any context. Caller may not sleep until they have called + * page_ext_put(). + */ +struct page_ext *page_ext_get(struct page *page) +{ + struct page_ext *page_ext; + + rcu_read_lock(); + page_ext = lookup_page_ext(page); + if (!page_ext) { + rcu_read_unlock(); + return NULL; + } + + return page_ext; +} + +/** + * page_ext_put() - Working with page extended information is done. + * @page_ext: Page extended information received from page_ext_get(). + * + * The page extended information of the page may not be valid after this + * function is called. + * + * Return: None. + * Context: Any context with corresponding page_ext_get() is called. + */ +void page_ext_put(struct page_ext *page_ext) +{ + if (unlikely(!page_ext)) + return; + + rcu_read_unlock(); +}