From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com [209.85.210.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43E8C405C28 for ; Thu, 4 Jun 2026 17:04:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780592647; cv=none; b=B5MzT0y7IBGkXhS6AuwufbWa7656TCjzws+HaBYzVWPRwOTDDHhOdHzZyJ8v8zjVUpr6aqdEnwGtZZ2pJWcJKUsb33UK6bfRrnObmDjK+8KaCGMuwG21qGSepciwY+o+TDpyho95SFz/XBg8Aroiqh2UR6ZGFSCXmyNIdMgcGZA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780592647; c=relaxed/simple; bh=2Oe5zI29QYBSaAVXXsLFuHw+T4Jtc2riK8xu4LdbPGM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WtzYEg/K+oWox/wUScu5a+TWoVlcYN4xxjUHJR8M++tVl59ZwzA0oj3JUVAW5tmIV9I+NyKebf4cRua3f1IAZfEzDB9Dc42IKDU0h37g/FmC85tp19n2wUFHpCqb/N/ShO/bXpwomjoP4vl186BvrNfKF5wypjCRGPReQRGXZ0I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VO+51NZZ; arc=none smtp.client-ip=209.85.210.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VO+51NZZ" Received: by mail-ot1-f51.google.com with SMTP id 46e09a7af769-7e690c213e3so770716a34.3 for ; Thu, 04 Jun 2026 10:04:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780592645; x=1781197445; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DcvudAyzInANCS3/gRy6s7uXW50Jd5n00LMZGa4M0Ow=; b=VO+51NZZTp4hxc3qpfPWJqD5xElv9n415ly/SwYwkF4xIj427eAGxW8ChsSZQX4msy 3WAoUUrfSl3I1pHHw9WXDN5vN33k/4ia4GdjHQbss/tWVnlVOd04Tm7EJ0dfvYCAN2bt wzeeGqp6InEnpEfd7URZWoJlSKKzZ5hlnt8eOgnPG9VWdSnRun3QIv5WLNyWk0iV66gq z+Bga9wnRAeKWXO07n11LNiSv9RUoc2GL7GRxnhBgTkwVJ13kyVYCHROZfxxCKstus29 8IOpHBE0cafT2wIUg4zJX1PO96Yi9o3AsgIlONTHPsg/ja4vpPshSvVHAkRAxHNQKlPB n1zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780592645; x=1781197445; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=DcvudAyzInANCS3/gRy6s7uXW50Jd5n00LMZGa4M0Ow=; b=UF4xle5j7b7wjaIGp0/jBIai7C7t7z31iyERsn1tKk4BOYWfzaXVMiz+a2gWH07r94 yJNlAA8Apx8ARNAljn1kVTVvLuGqxDN2P8iAzRarxXVrchXaAq3HnRnJsxhiO/NOso+Z i2SSHpjwA78g3/it4fFYjU9RHHlaI34GVEj2jJIKGpJ7rYMtBIjLxSuCW215opAEWS6Z lpLe8Ccwop0+5Y6Z8r/GaOwRuWDd3AFGOXVGGPJc9rCydSEGKHP1VB7aIuQvw2AeXnPO Pp22XfJuZrucvlqdHHD8RJtw6cJFNdk3WJnyIcpCDItMzOfOBfEvDkGunpqttIQyo/pZ baJw== X-Forwarded-Encrypted: i=1; AFNElJ+0iy2NbuDrBQ7iZTTRLVpScLvL+qmUyt9pVqIAw1SQhG0Gz3/OxKCMtwYmM4u7tE8CxdHwbHA+DhZuSxQ=@vger.kernel.org X-Gm-Message-State: AOJu0YytZ6SR61uoJa8hHoBKjeBqKNVnzeuVnDGKJedEgyzarJaIuxm4 REMoUpGktPZNHdTfeY/cl/r+NJElQWMay3KF0z9++HtKRB7WDZ4WP8Go X-Gm-Gg: Acq92OHr1iNAcm1dH+c9ULxHLyuMptMN/ZJK6fdNTtb2M9FA8l2uekdpCyGOr902zI0 BeAtg5fL+zDHvIItJFnjIVTe2muPEoHlDXjFr+PUMShONcaAD/KBbo/luySxk4g/ovjntTJqchC Ui/C24JuCjdkoF6EjDmw/2C+PUlsAJz6r0Sndw5RLfIwY/1R1rZjSH5/Ml9t+iD9l2w8ggPFyUc 4y7IyCyrcbFNcymi40/OYypbR2MptA1EdabAWykAXCxGUo/UKqXLngCthNByNwG2JQBuHJyiUPA Yb3zOMBpVht4/pEMvZvyNUlN3qwFTsVKpGVjdBuVW/9c0t6QVE4PUTabNEj5N2EwzJamB3KSksu hB0E/kICs5OOOZDh/a17q4H8Tl27/mo5ZCjAjbRmrWS7o8HYIy04hAEDacTqFWlNsOV3al3m5n3 1D4F7vVMtA6eUF9TbH4NnsRi7ZDFERKBbrUW8bCrHYGPblfsr//9csCCD/Mz0t3VFS X-Received: by 2002:a05:6830:398c:b0:7dc:de56:d75a with SMTP id 46e09a7af769-7e6e94ae42emr5492401a34.4.1780592644725; Thu, 04 Jun 2026 10:04:04 -0700 (PDT) Received: from localhost ([2a03:2880:10ff:71::]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7e6e78de8bdsm4114971a34.16.2026.06.04.10.04.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 10:04:04 -0700 (PDT) From: Joshua Hahn To: Imran Khan Cc: akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org, liam@infradead.org, vbabka@kernel.org, rppt@kernel.org, surenb@google.com, mhocko@suse.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/vmstat: avoid taking zone lock in /proc/buddyinfo reads Date: Thu, 4 Jun 2026 10:04:00 -0700 Message-ID: <20260604170401.1401791-1-joshua.hahnjy@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260604134245.1580287-1-imran.f.khan@oracle.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Thu, 4 Jun 2026 21:42:45 +0800 Imran Khan wrote: > frag_show_print() just reads zone->free_area[order].nr_free, so > it can safely do this without needing the zone->lock. > > Pass nolock=true from frag_show(), so that walk_zones_in_node() > can skip the zone->lock acquisition. Hello Imran, thank you for the patch! Seems reasonable to me, and I think this sentiment was already explicitly encoded in a comment block in frag_show_print: /* * Access to nr_free is lockless as nr_free is used only for * printing purposes. Use data_race to avoid KCSAN warning. */ seq_printf(m, "%6lu ", data_race(zone->free_area[order].nr_free)); Plus, we have a data_race() here so it seems like lockless reading was always the intent anyways. So: Reviewed-by: Joshua Hahn Digging into this a bit more, I did find something worth noting. Commit af1c31acc85325 "mm/vmstat: annotate data race for zone->free_area[order].nr_free" was the commit that added the data_race() here, in response to a KCSAN report. But looking into it, I don't think KCSAN was reporting a data race for this callsite, it was actually reporting it for a different one in extfrag_for_order->fill_contig_page_info. Maybe the author there added the data_race() for frag_show_print just to be safe as well, even though at the time it was protected by a zone->lock anyways. Just something I thought was interesting to note. Thanks again! Joshua > Signed-off-by: Imran Khan > --- > mm/vmstat.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/vmstat.c b/mm/vmstat.c > index f534972f517de..7b93fbf9af092 100644 > --- a/mm/vmstat.c > +++ b/mm/vmstat.c > @@ -1568,7 +1568,7 @@ static void frag_show_print(struct seq_file *m, pg_data_t *pgdat, > static int frag_show(struct seq_file *m, void *arg) > { > pg_data_t *pgdat = (pg_data_t *)arg; > - walk_zones_in_node(m, pgdat, true, false, frag_show_print); > + walk_zones_in_node(m, pgdat, true, true, frag_show_print); > return 0; > } > > > base-commit: e43ffb69e0438cddd72aaa30898b4dc446f664f8 > -- > 2.34.1