From patchwork Tue Jul 9 03:19:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13727206 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 EB865C3271E for ; Tue, 9 Jul 2024 03:20:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 51EFB6B0089; Mon, 8 Jul 2024 23:20:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4CD8E6B008C; Mon, 8 Jul 2024 23:20:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3473D6B0095; Mon, 8 Jul 2024 23:20:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 144BC6B0089 for ; Mon, 8 Jul 2024 23:20:05 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id AD7F7161531 for ; Tue, 9 Jul 2024 03:20:04 +0000 (UTC) X-FDA: 82318760328.21.E833DA1 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) by imf01.hostedemail.com (Postfix) with ESMTP id 057FD4000D for ; Tue, 9 Jul 2024 03:20:02 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=meIZULrx; spf=pass (imf01.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.167.52 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720495187; a=rsa-sha256; cv=none; b=XrgBwKq3MUVSXrfFL6w+cTqOJIHoiDoFNalLmOASw4C4eIruUAMbLLangNlz2eeLg55+VE 9aEEw4H3yKn6kdjBv6NgRIEVwqDT/QOCtUCRDDGsBqCzXktuimZFSudYQdent7vLv0ZIDT Jvcq1PsbjEMxs0xku0uJd92WOZPBbSA= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=meIZULrx; spf=pass (imf01.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.167.52 as permitted sender) smtp.mailfrom=richard.weiyang@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=1720495187; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references:dkim-signature; bh=ZQKr+whq8TOtGQxoKiYNa2wqoQu2v+GxHTyIQG7PwmE=; b=M1XFPM2UiovbyYg3VZiKTohly+TDg2aaMXQQlGTHizaNgiXjoPHFiXplHFyBzZi/+yWvz9 DE3n6xWw9xrKsCcGYjqcsdOh3b7dPHcszMdq/9olNemB4Q4LwMHBawXXdXyc3yx8FtwKVA Gzj0RQlw2e708qeDGmwds3CMTong/VY= Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-52e9fe05354so6829075e87.1 for ; Mon, 08 Jul 2024 20:20:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720495201; x=1721100001; darn=kvack.org; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZQKr+whq8TOtGQxoKiYNa2wqoQu2v+GxHTyIQG7PwmE=; b=meIZULrxPsl3Vo0Wcf0T7ce5dtTahxq4BZD2+nH5uBiDpCM1B1JEbjFQjqFIQoC0c4 s3hhvOaOXuV3NUmcrd4kSunSeneTwJ/8F8219UAohWPAjd6XYglLPZVpq9broyTU6xv5 ea9vBX5lFOIQZvEvxROO7UN/+jUoVtBTxIyBCQd36lru0O4n3/XA6Es1WFUgT4a3z1Fm faVqjl4BJKCwyfkCrDhdGgbidHH+nRCLmjBDfDkQpCmFGhmxet6OrfKh2V7eSN+F/ctf UT1G8ngOXmhJ5T/CpFkTCZ2PbLuxlH7zvw+pU6lBTxCHG34W9koPxdQDwvTcX6SZVeBl bAmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720495201; x=1721100001; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZQKr+whq8TOtGQxoKiYNa2wqoQu2v+GxHTyIQG7PwmE=; b=ijiAkqW3ADOn0YGBIaFf8cGupn+RME8geoBMivv5PYNjZzTjuGvyfe+Hs0q3BFmORn W4rYGD7+e6Q3k1VNzsWAhMq5ehRedmv6MTdKWO1bZY0HWHQlOVKOP990t8VnsXMwuQzg XzLDI4E9Vh/TRY27BzV7eCbflaRLf0OOPiVyay/n0DkZRCKzG8l1ADYaN2C3UF8LBB2p DBMR9FatIWRWBAEK2U79wUGnAOC3A7ICY51v5ikURdSWsfzRpleKtgVvAFnJyl3JGxEQ 8BWU4LsbrmO4GHLQ7hxwAKkFKZHQCdhqX8l50nUkRvQm05sLmjEX3GrYUS1jY6xSxmwK QOKg== X-Gm-Message-State: AOJu0YyOrS7QeXvBGPVRkopm+LPBlY4Ai2WHXpDMgiVfK/UR74C91c0b 6wNfu5A8GcCUWi7Hc5nwl4UaFw4zTXXbcgJhV8rM58mSUedMHlAO X-Google-Smtp-Source: AGHT+IEtlizg1sc79YvzHshZXSyrF4qFgsb0EAHR7SpuKQb3v6kLgSyYuKlT+g2X2V/KdZxAwH8L6w== X-Received: by 2002:a19:ca13:0:b0:52e:9f93:6f13 with SMTP id 2adb3069b0e04-52eb99d2092mr600751e87.54.1720495201264; Mon, 08 Jul 2024 20:20:01 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-594bda30f76sm526377a12.97.2024.07.08.20.20.00 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Jul 2024 20:20:00 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang , Mike Rapoport , David Hildenbrand , Garg Shivank Subject: [PATCH v2] mm: use zonelist_zone() to get zone Date: Tue, 9 Jul 2024 03:19:53 +0000 Message-Id: <20240709031953.22217-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 X-Stat-Signature: qyuoqyakbf5ayyax7aq588aak5ukhndw X-Rspamd-Queue-Id: 057FD4000D X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1720495202-569478 X-HE-Meta: U2FsdGVkX1+sG8uFdZdVGAhDwO9sxeJvwWW3STPIHaTi0q0gRgPqW5D+rPPwPAPXL8Ya0SWj6ebhwy1ehVZ7Z48geAK2wPxaymzBvB7X9VSvtZMhjQeKM6dxf31WYm8927skCGPcztZVtjpg2fo8ZPaVvjpFUqHRq0KnqBCp6xcanL/Q6gSxl3RhwDUjvtd+N4OFW7kpxbmQmByYs4t3r+1i/LfH6qVkeuGLZ6Xv1sqKuBoouM7ogdMNDksqxb/9/y0h6+wYWFjQoI7LmJj68d3g4VgTPjmM2S+ZjAAthtnyXbY6XUNhXdmFk7jI5AvbxnPZhDFYhCBKnf+hSnhV9mtYLKqP6PSYCqKtys1NljRrNQks2X2fQBIm/RHAvUmr50VBHdKnnatoEP9+D4jkn2BnAx049zL6e+Pt+r1GWypvUNvHn1g4rtVaqWeRLG7nzulfZSE2RozzrQ259pFp5BoFAOUoSpGR1o/kzpJkkKM+SBbJzxLyGVM4/iOwI8d6QIeTFM0hcaD4ctlvGpjeHQaNTkCdqZRtZTdmzzMHn7BUVk6TraN9hhKdz61zS1v9GQ+rewAq+bPPQmLGBJEY9EiKuT8U6heqKnzVwHSk8fuSFpfI89ju7jsYGtNVL3eExVxbqyOgp5EdmWJAJWDf7FSIsn/ytrb8sZ8v1WNDlqlOvisVzZlJCfKqsAJBlc1KL5xqYkjMK117MiGgC4B2RIh14ESi0yU8nYXWjwYvjGOE/Ya2w+gZhqv8Z08bgukw65lMbl/NEQ3985vqpUk5nXcHBdptQCqXptUYjZWhWfUnQytO9O8X9eIPstoORrPD/WIH+zNiFJB68ufRK/P+DTQCSY1uzYVSpHJdU1ComCLUxXO+xSovWzOz3Mzf02eaAKz/l9lonm+d24VGVunOKkjLSkS5nVhNQ0CPen+7fwEVSqCzzgZ7199SVC+zEj4I7QQZMLWlR+H9eAk5dgg T/mmgjdD KiFGGYfyg7hURPw/CAN7SvnDQ45LbNDwOR6AdZNPsjM1xIx1OFPhOEAr1xhpAJKxFBjvJ8DGjxNb7RXgIk5bY76niISUPr8QmOyRMU9cPhgh++NDLUyzDsW6mZc808vPcXW/TY8OQ3u8SVD7U9sWuHDXLyLlLdYU2PXP/+IRApNN9XGFNlalhJr+9CWu+Dh0YVXsBX8KevtOqWB76Wwu8MzHNAMgjmVf4XivnTK8wcf30SjfF1Fe+tyKNuH4EDSApxtp2z2o8bHGE26f6MevN3m02o0Z4RL0Kz2+hmUMTvkF4MlHiW1NjZNPf3bwpXZXCZOYuSASOJZLSu0ITqK2LfbZUigpJXCmsz4wbww0WZhllBQQdHMzKyP55K092h93jgdR2ngDgP3VWcAXGbPhPkS1rKFWTKygtm/jBnYYhSpQZg1WqquCimXPyJ4shley2Q7OTJ3Dj5Uernap7UyUf+/nz2NJw1dTGwZKMd44kJKXHrpPLI0Fy4y6WzBAWQnirATq8nnxbhdcIYC2d9/5EnpM9hddSqodNgf4diKJ59REWQq2yxP7bs8FJTQ== 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: List-Subscribe: List-Unsubscribe: Instead of accessing zoneref->zone directly, use zonelist_zone() like other places for consistency. No functional change. Signed-off-by: Wei Yang CC: Mike Rapoport (IBM) CC: David Hildenbrand CC: Garg Shivank Signed-off-by: Shivank Garg --- v2: cover more usage --- include/linux/mmzone.h | 4 ++-- include/trace/events/oom.h | 2 +- mm/mempolicy.c | 4 ++-- mm/page_alloc.c | 14 +++++++------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index cb7f265c2b96..51bce636373f 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1690,7 +1690,7 @@ static inline struct zoneref *first_zones_zonelist(struct zonelist *zonelist, zone = zonelist_zone(z)) #define for_next_zone_zonelist_nodemask(zone, z, highidx, nodemask) \ - for (zone = z->zone; \ + for (zone = zonelist_zone(z); \ zone; \ z = next_zones_zonelist(++z, highidx, nodemask), \ zone = zonelist_zone(z)) @@ -1726,7 +1726,7 @@ static inline bool movable_only_nodes(nodemask_t *nodes) nid = first_node(*nodes); zonelist = &NODE_DATA(nid)->node_zonelists[ZONELIST_FALLBACK]; z = first_zones_zonelist(zonelist, ZONE_NORMAL, nodes); - return (!z->zone) ? true : false; + return (!zonelist_zone(z)) ? true : false; } diff --git a/include/trace/events/oom.h b/include/trace/events/oom.h index a42be4c8563b..fe6997886b77 100644 --- a/include/trace/events/oom.h +++ b/include/trace/events/oom.h @@ -55,7 +55,7 @@ TRACE_EVENT(reclaim_retry_zone, ), TP_fast_assign( - __entry->node = zone_to_nid(zoneref->zone); + __entry->node = zone_to_nid(zonelist_zone(zoneref)); __entry->zone_idx = zoneref->zone_idx; __entry->order = order; __entry->reclaimable = reclaimable; diff --git a/mm/mempolicy.c b/mm/mempolicy.c index f73acb01ad45..83e26ded6278 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1951,7 +1951,7 @@ unsigned int mempolicy_slab_node(void) zonelist = &NODE_DATA(node)->node_zonelists[ZONELIST_FALLBACK]; z = first_zones_zonelist(zonelist, highest_zoneidx, &policy->nodes); - return z->zone ? zone_to_nid(z->zone) : node; + return zonelist_zone(z) ? zone_to_nid(zonelist_zone(z)) : node; } case MPOL_LOCAL: return node; @@ -2806,7 +2806,7 @@ int mpol_misplaced(struct folio *folio, struct vm_fault *vmf, node_zonelist(thisnid, GFP_HIGHUSER), gfp_zone(GFP_HIGHUSER), &pol->nodes); - polnid = zone_to_nid(z->zone); + polnid = zone_to_nid(zonelist_zone(z)); break; default: diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 116ee33fd1ce..e2933885bb19 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4218,7 +4218,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, */ ac->preferred_zoneref = first_zones_zonelist(ac->zonelist, ac->highest_zoneidx, ac->nodemask); - if (!ac->preferred_zoneref->zone) + if (!zonelist_zone(ac->preferred_zoneref)) goto nopage; /* @@ -4230,7 +4230,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, struct zoneref *z = first_zones_zonelist(ac->zonelist, ac->highest_zoneidx, &cpuset_current_mems_allowed); - if (!z->zone) + if (!zonelist_zone(z)) goto nopage; } @@ -4587,8 +4587,8 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid, continue; } - if (nr_online_nodes > 1 && zone != ac.preferred_zoneref->zone && - zone_to_nid(zone) != zone_to_nid(ac.preferred_zoneref->zone)) { + if (nr_online_nodes > 1 && zone != zonelist_zone(ac.preferred_zoneref) && + zone_to_nid(zone) != zone_to_nid(zonelist_zone(ac.preferred_zoneref))) { goto failed; } @@ -4647,7 +4647,7 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid, pcp_trylock_finish(UP_flags); __count_zid_vm_events(PGALLOC, zone_idx(zone), nr_account); - zone_statistics(ac.preferred_zoneref->zone, zone, nr_account); + zone_statistics(zonelist_zone(ac.preferred_zoneref), zone, nr_account); out: return nr_populated; @@ -4705,7 +4705,7 @@ struct page *__alloc_pages_noprof(gfp_t gfp, unsigned int order, * Forbid the first pass from falling back to types that fragment * memory until all local zones are considered. */ - alloc_flags |= alloc_flags_nofragment(ac.preferred_zoneref->zone, gfp); + alloc_flags |= alloc_flags_nofragment(zonelist_zone(ac.preferred_zoneref), gfp); /* First allocation attempt */ page = get_page_from_freelist(alloc_gfp, order, alloc_flags, &ac); @@ -5310,7 +5310,7 @@ int local_memory_node(int node) z = first_zones_zonelist(node_zonelist(node, GFP_KERNEL), gfp_zone(GFP_KERNEL), NULL); - return zone_to_nid(z->zone); + return zone_to_nid(zonelist_zone(z)); } #endif