Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1588168lqa; Mon, 29 Apr 2024 12:47:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUSJxf3yjhpwDdDmfNW/YKxYENvwL1CP3M0JjoHHsur+d5cRuKB278X/Cq5psP6a2zkehc7wcp9E5eBHZYOnwaA+CcH+qL63sbY5SPV1g== X-Google-Smtp-Source: AGHT+IEOGWEup7/mD+6pyr+ayu3WxOwdU35hg3ZI78FuDOv+avBrj9T3jbSkynf4BgXXEiZ90Kym X-Received: by 2002:a17:90a:aa8e:b0:2a5:be1a:6831 with SMTP id l14-20020a17090aaa8e00b002a5be1a6831mr875389pjq.19.1714420054551; Mon, 29 Apr 2024 12:47:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714420054; cv=pass; d=google.com; s=arc-20160816; b=GRKyfwkWtmQuwXiZV6zEJ2+E6xasgNAG/Fj/Pm0rv2/wHxrpBvjQTi+Nunwxxuysig +BXsgUAi/QyWUF+1Vb5H05uh4SXO8r8IH/c+gSmPQC1x+rGjolM3ZOFsVsh/hrnOLNfE GlkQSegbqkUAJd4n9nB6eLHbLPwF8qyfJl65oqJ+Rum7aYPj6bzczvfpZLZUl0C0F4Oz 04YOcv0v2RUpqWEeiI8XqSPhgtP71AWul+eRzuWphYAqi2Y7sTovSbKK3PEfzSinAP3c glHZSa88sXtHp5DaEzlVAvJcroDTVimVP9ped/6+3OtSCODAtTnePRkJrPbw1/UGiHBw 9ALA== 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=y1WEB6RzCqCuX7Z+BbEKtZP6s+NxySx/uW1PWUvKOFE=; fh=EtmzgUDl7YWyKMNs6TjPGPlxEbIQxspZo+ZGll7FwB0=; b=OBG8WU4qPlH9brqOT6CTxMmvTegVrP5S8n/vDQfrqTT69EEq6pp6NVUUurfp7DglS/ SvaaNiTDkPMDyX/2rx0C2PGKiYlpBes48RRUXTLJAEY4vj+SWeb95SqsiShywNG0jqq8 4+UrJa3kdvnBdGes6yoILN2eRvp7BQTqA5YotnW3Qlm3pdryQhLExLN46shECLQ+xye+ cACbdlt300w0m8JKTs4qzCyvMdsGjbA6qN9oUnVMKHRNIeyqv1FbSoHsC5C2wkEYNyj9 ORpi2wXsQV9Sk+KGk6GUMp8NKqgCdTRl8xF9aPcl2rtvQQnKt5m0UpbFuz2xq4/j1cxB h73Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=sgWt1An2; 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-162966-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162966-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x64-20020a638643000000b005f7fd30b1dcsi18092188pgd.106.2024.04.29.12.47.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 12:47:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162966-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=sgWt1An2; 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-162966-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162966-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 41F1D28149D for ; Mon, 29 Apr 2024 19:46:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 33E3B13B587; Mon, 29 Apr 2024 19:46:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="sgWt1An2" Received: from out-179.mta0.migadu.com (out-179.mta0.migadu.com [91.218.175.179]) (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 B2787839FD for ; Mon, 29 Apr 2024 19:46:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714420001; cv=none; b=OHFfxGSv1Y5xHDbkHWBPLx8Io2NKVR/4fLMlw6gEC15PRbF51hu1qMCwWMjcJ6zmvwx4feq5mqmVs2Rtp/28LthSgw5EoK5/6SZ1y1OZhm2hCVVS6q2o8uZx11xxLikK9HL/CTA5BdZUrdoBJuNrljngxnq+/tSzyNL63yT4pb8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714420001; c=relaxed/simple; bh=a0MCZvyt3kJaAOrmL3OAu/2EhxYaFMLR5UetA8zD4NY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=o6bB0TAzDCB2jBX9TxQNdquMan9c1NtEKGYVuVhJuETezWKVhqVetI/zg0mdspBhWPlmiPNI6IalUIXf5O0laSqmrKJZn69Q9EFIFY75GyKQ56u2GUQw8yq2V4zmPPm61Cw9ASAR6yQZOdsnOS1bSm+dRIUIkeRuiD4AqxQUcvA= 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=sgWt1An2; arc=none smtp.client-ip=91.218.175.179 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:46:32 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1714419996; 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=y1WEB6RzCqCuX7Z+BbEKtZP6s+NxySx/uW1PWUvKOFE=; b=sgWt1An2hPV1lyHHvEXOIJtMsZZlCWBtR2Rb4kypKeBamwx3dIlZyBHzI1a2c+l826ZZXr Pn205wwwOjaAvRHFCqLFJU9A7zWx27uVJvOrKyVic7BvVQ6SPQrIGME921+LD9smTvsmRP i4iBTSQrlmze93ONreGziI4zAbBKGrg= 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 2/7] memcg: dynamically allocate lruvec_stats Message-ID: References: <20240427003733.3898961-1-shakeel.butt@linux.dev> <20240427003733.3898961-3-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 08:50:11AM -0700, Roman Gushchin wrote: > On Fri, Apr 26, 2024 at 05:37:28PM -0700, Shakeel Butt wrote: [...] > > +unsigned long lruvec_page_state_local(struct lruvec *lruvec, > > + enum node_stat_item idx) > > +{ > > + struct mem_cgroup_per_node *pn; > > + long x = 0; > > + > > + if (mem_cgroup_disabled()) > > + return node_page_state(lruvec_pgdat(lruvec), idx); > > + > > + pn = container_of(lruvec, struct mem_cgroup_per_node, lruvec); > > + x = READ_ONCE(pn->lruvec_stats->state_local[idx]); > > +#ifdef CONFIG_SMP > > + if (x < 0) > > + x = 0; > > +#endif > > Not directly related to your change, but do we still need it? And if yes, > do we really care about !CONFIG_SMP case enough to justify these #ifdefs? > That's a good question and I think this is still needed. Particularly on large machines with large number of CPUs, we can have a situation where the flusher is flushing the CPU 100 and in parallel some workload allocated a lot of pages on, let's say, CPU 0 and freed on CPU 200. > > + return x; > > +} > > + > > /* Subset of vm_event_item to report for memcg event stats */ > > static const unsigned int memcg_vm_event_stat[] = { > > PGPGIN, > > @@ -5492,18 +5546,25 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node) > > if (!pn) > > return 1; > > > > + pn->lruvec_stats = kzalloc_node(sizeof(struct lruvec_stats), GFP_KERNEL, > > + node); > > Why not GFP_KERNEL_ACCOUNT? > Previously struct lruvec_stats was part of struct mem_cgroup_per_node and we use GFP_KERNEL to allocate struct mem_cgroup_per_node. I kept the behavior same and if we want to switch to GFP_KERNEL_ACCOUNT, I think it should be a separate patch. Thanks for the review. Shakeel