Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1592546lqa; Mon, 29 Apr 2024 12:58:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX4PH0oLTC1LL3AEhO1n8O6k8qnD3qobw2aMkcc/i6Op0jVCi5GaPTyCu49liSBZtEkhwegui9Lo5N1Krv5yJ1Unhv2zUfMY7Y/YsvwwQ== X-Google-Smtp-Source: AGHT+IGzZuLl6PK4WxHm8c+LA2JRVDP3tLqjJm0yUFPGktc3bRMDndMzn9IrYtug2KdIDuq7XjXE X-Received: by 2002:a17:902:f70d:b0:1eb:5403:b16 with SMTP id h13-20020a170902f70d00b001eb54030b16mr9314507plo.0.1714420710991; Mon, 29 Apr 2024 12:58:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714420710; cv=pass; d=google.com; s=arc-20160816; b=RhrKK0dcQQEGkCt/uMT2j1GAqMrKoT5AbDBrJtyF/m3jyI/cN4D4qJbzf6tH6VStKM 7oFJ8E4Sm3LWOP+T5qytJy3guBdWByRo2RNY1VJxAduGFoDC7hsvDAWq+nczAa9ZOD7g PML3eyIdsqDRaMKQvjxMwJBKGFGTrFjys4qJbITNAsviz+RnNEQdFTeWQpCZQe47z0YQ PvaDkQqYCmkeF8/22ZWhJcPZfLd8sdlodrunqzRM4Ene5iI9B0GsqnQ9C+iIfb8/t00o ISR/Wi5JyYy4EuWuxawMaIA7WNuZZlB2AhyEQ3pl/YV57rqfUsoncsFR9lKc+pN18eTq nzwg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:dkim-signature:date; bh=mxSwxDMr1PsnyOzythgKPWt6orPHRWexAENBx6E26ik=; fh=EtmzgUDl7YWyKMNs6TjPGPlxEbIQxspZo+ZGll7FwB0=; b=jK37Evlhn2oQpYhMAAstbMcdnwqTPqykR+RucXYbY6nBxHs8TQ/TIH8r6t+Y5sawyv ejhMxSTXU8bv9BwQltrrjjX1BFMcsV/8LLPQ8+oqPoR8ipj4zt9Xk3rLHUG/e0RRFPKM RWi4zQEWOmVQNp4mINHgbgSGAbRr8YCxK8KFAwWmupH76cqpNMmxfwpY//I81fknUX6z 160ABmuTI8ISTe9AR26s5oCBWDRK0J/ykV+Df8aD1wCXcXbJAppsPdEYcsxAY/m0unsr MagtGVpKz82jYT+w7zXI0Jb5Ndj4b/VshQc/jGw8mzdB06zXJqneKl40f87gHgDIeECs SEHQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=HUZ44vPb; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-162977-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162977-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id lv13-20020a1709032a8d00b001eb1f82c41dsi5849605plb.229.2024.04.29.12.58.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 12:58:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162977-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=HUZ44vPb; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-162977-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162977-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A4D30B20F79 for ; Mon, 29 Apr 2024 19:56:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BA95E13B2AD; Mon, 29 Apr 2024 19:56:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="HUZ44vPb" Received: from out-178.mta0.migadu.com (out-178.mta0.migadu.com [91.218.175.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DC2513247D for ; Mon, 29 Apr 2024 19:56:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714420592; cv=none; b=OV0XylWToOdGloUERsrhRgbQ2LmhXMApHgC5YtojIac8ftgio+kE5z53gaxVaSWevKc6mhjaWUUGWC+3bSCk27FWINdAdKVTV8Cqrw7IAaPt7a9WMNDcFrvZoueYC29aF++qwZljYQh0+cGuLy2vqbiHPbbLX2qdXQVPK63iWXQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714420592; c=relaxed/simple; bh=w0oorwqXbrMrKPsb6M/aRLQrz/nsFuZ0VYTdqgpRW+M=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=t5Uu5Ra9Xpylgp24vANB0F5CMewz4IRXPDMtnZrP4LOXFVQqIY4MZVQ0IPbm8lnPx0987EYtMM0s7xz43LPeZ4tgKLFYx6EfbjPRfej1cdTEz3kGv1+FmiMe+nj3qhrXCPfcYOpa5CQyy02sT7xxaFD/pileqpMeJ6Mo967XOh0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=HUZ44vPb; arc=none smtp.client-ip=91.218.175.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Date: Mon, 29 Apr 2024 12:56:25 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1714420588; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mxSwxDMr1PsnyOzythgKPWt6orPHRWexAENBx6E26ik=; b=HUZ44vPbbhgAmbzwCGAm+Lo/ZtUT67pE2IJvRjQGLyTesQGJJF8P7ZbZZAC09WpbeTFDd/ BoZpivwMQ+8X6rGu8xamvaiwIXz2b84nGEczaBO/BV+yEpgCy5jK4SpYRDWytUgrdG1C1m 3xD/xxu3zVQkjqMO4hi9Nq6l9DEzRjY= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Roman Gushchin Cc: Andrew Morton , Johannes Weiner , Michal Hocko , Muchun Song , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 5/7] memcg: pr_warn_once for unexpected events and stats Message-ID: References: <20240427003733.3898961-1-shakeel.butt@linux.dev> <20240427003733.3898961-6-shakeel.butt@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT On Mon, Apr 29, 2024 at 09:06:23AM -0700, Roman Gushchin wrote: > On Fri, Apr 26, 2024 at 05:37:31PM -0700, Shakeel Butt wrote: > > To reduce memory usage by the memcg events and stats, the kernel uses > > indirection table and only allocate stats and events which are being > > used by the memcg code. To make this more robust, let's add warnings > > where unexpected stats and events indexes are used. > > > > Signed-off-by: Shakeel Butt > > --- > > mm/memcontrol.c | 43 ++++++++++++++++++++++++++++++++++--------- > > 1 file changed, 34 insertions(+), 9 deletions(-) > > > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > > index 103e0e53e20a..36145089dcf5 100644 > > --- a/mm/memcontrol.c > > +++ b/mm/memcontrol.c > > @@ -671,9 +671,11 @@ unsigned long lruvec_page_state(struct lruvec *lruvec, enum node_stat_item idx) > > return node_page_state(lruvec_pgdat(lruvec), idx); > > > > i = memcg_stats_index(idx); > > - if (i >= 0) { > > + if (likely(i >= 0)) { > > pn = container_of(lruvec, struct mem_cgroup_per_node, lruvec); > > x = READ_ONCE(pn->lruvec_stats->state[i]); > > + } else { > > + pr_warn_once("%s: stat item index: %d\n", __func__, idx); > > } > > I think it's generally a CONFIG_DEBUG_VM material. Do we have some extra > concerns here? > > Having pr_warn_on_once() would be nice here. No extra concern, just want this indirection table to be up to date in future.