Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1635723rwi; Mon, 31 Oct 2022 20:19:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4rYegvZJnprXT/7pBtQaRcfbHR/i16vYhG0cAbiU66onlHWdPHkJQvDC8ILKVNxYfQhWuU X-Received: by 2002:a17:902:bf08:b0:178:90fb:8cda with SMTP id bi8-20020a170902bf0800b0017890fb8cdamr16988744plb.9.1667272766437; Mon, 31 Oct 2022 20:19:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667272766; cv=none; d=google.com; s=arc-20160816; b=LO3Qs81vwkIGsYioWgk9MAfxde27gw7FpbQmDzQOiGEZubh/xKbIB3UvB1S9TePAla ULJYKpMjueoO6H5Wmpl30bZLLxURL72QjzvWnk0uOfblDqhPZ1+ctVUQy78gRXjk/6w/ tAgwPxOnd4j2EfwuDsQLnr813iQ/b5Rpvr9vXtNC7xRU3Cld85uMp+B2rKgflcxcxKac rH/1OhqhPUyyb3JnojasqH3GunVTfPzYmDd/sqCop7Kq/oWhS9mIZaKgVqpIwFQzvhIx XEv4+vK0WDCCTvWfafS0EJwJDp3EeTp/dMewhXquSgnEt6LYcF3i7MmAjs6Q/Oozzvtp tt8g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=6TefmdO43ILS61YweujCpCvfdLxa126KkuiZEMMTg3c=; b=PsNf8Hhwr3wQ2O4K8Ch9iIUww4EP6Wq+t3uS9aAgTMUPmyNIz2ddJPfrx0DUa1nVHQ JLhhVNVFwrNi/3QX9JU5Ym6E3kacUTHCBzeFQID9k4KO5m39suIomVb1j7+4QrSGuFZh 5pMZdjIOEkzw2gOLwh9jQ4RmiRWcq6DqXuJ95zowwDPwPlIcaSetU19UkTekFmj+9wmr I619wWPmviMFnRZFCquHQfq6cvp3p1t3lqnmzW1+7Moa4qb7miQNHr8+J4/BdiAX32g7 Sab1cX0wWf2rP9ZZ0uKgSfZsPjBLDzpXT6GtGmOIQk/IKt22a07LT3x2BKRHSMCmeGym hjSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=XDksCaR5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cd20-20020a056a00421400b0056c45eb2147si10786263pfb.51.2022.10.31.20.19.13; Mon, 31 Oct 2022 20:19:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=XDksCaR5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229642AbiKACc6 (ORCPT + 97 others); Mon, 31 Oct 2022 22:32:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbiKACc4 (ORCPT ); Mon, 31 Oct 2022 22:32:56 -0400 Received: from out0.migadu.com (out0.migadu.com [94.23.1.103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E94DCD5 for ; Mon, 31 Oct 2022 19:32:55 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1667269973; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=6TefmdO43ILS61YweujCpCvfdLxa126KkuiZEMMTg3c=; b=XDksCaR5tYi0qjMnF2RCdEumv8O4KTNHiCx2EzDr+cook6Vf/kFA5lFqVhAEJ0Yt+S7OhS GZTAuWKLRQ6a+mV8tVwuh4waKnVvf7yfnl5h54TkjbpA5LK2cJ64bDyXMIrQFfE/JW0il3 MtnXj0qcp5h3/PeC5Bw2UDAiy+6b+bk= From: Yajun Deng To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yajun Deng Subject: [PATCH] mm: simplify page_zone() and get_deferred_split_queue() with page_pgdat() Date: Tue, 1 Nov 2022 10:32:19 +0800 Message-Id: <20221101023219.752365-1-yajun.deng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org page_zone() is too long, we can shorten it by page_pgdat(). There is no need define pgdat variable if memcg isn't NULL, so use page_pgdat() to simplify get_deferred_split_queue(). Signed-off-by: Yajun Deng --- include/linux/mm.h | 8 ++++---- mm/huge_memory.c | 7 ++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 978c17df053e..25ff9a14a777 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1448,14 +1448,14 @@ static inline void page_kasan_tag_reset(struct page *page) { } #endif /* CONFIG_KASAN_SW_TAGS || CONFIG_KASAN_HW_TAGS */ -static inline struct zone *page_zone(const struct page *page) +static inline pg_data_t *page_pgdat(const struct page *page) { - return &NODE_DATA(page_to_nid(page))->node_zones[page_zonenum(page)]; + return NODE_DATA(page_to_nid(page)); } -static inline pg_data_t *page_pgdat(const struct page *page) +static inline struct zone *page_zone(const struct page *page) { - return NODE_DATA(page_to_nid(page)); + return &page_pgdat(page)->node_zones[page_zonenum(page)]; } static inline struct zone *folio_zone(const struct folio *folio) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 1ed245f6d1a7..a524db74e9e6 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -562,19 +562,16 @@ pmd_t maybe_pmd_mkwrite(pmd_t pmd, struct vm_area_struct *vma) static inline struct deferred_split *get_deferred_split_queue(struct page *page) { struct mem_cgroup *memcg = page_memcg(compound_head(page)); - struct pglist_data *pgdat = NODE_DATA(page_to_nid(page)); if (memcg) return &memcg->deferred_split_queue; else - return &pgdat->deferred_split_queue; + return &page_pgdat(page)->deferred_split_queue; } #else static inline struct deferred_split *get_deferred_split_queue(struct page *page) { - struct pglist_data *pgdat = NODE_DATA(page_to_nid(page)); - - return &pgdat->deferred_split_queue; + return &page_pgdat(page)->deferred_split_queue; } #endif -- 2.25.1