From mboxrd@z Thu Jan 1 00:00:00 1970 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 D4F15C282EC for ; Tue, 18 Mar 2025 00:44:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C2D6280002; Mon, 17 Mar 2025 20:44:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1738D280001; Mon, 17 Mar 2025 20:44:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 03C99280002; Mon, 17 Mar 2025 20:44:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id DAD9C280001 for ; Mon, 17 Mar 2025 20:44:18 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 67E111A078D for ; Tue, 18 Mar 2025 00:44:19 +0000 (UTC) X-FDA: 83232825438.22.3254A20 Received: from out-183.mta1.migadu.com (out-183.mta1.migadu.com [95.215.58.183]) by imf28.hostedemail.com (Postfix) with ESMTP id A1D2AC0006 for ; Tue, 18 Mar 2025 00:44:17 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=TpjbFmcB; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf28.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.183 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1742258657; a=rsa-sha256; cv=none; b=snVW2mwgGJvMty4q037mVn6nAlqkKwyLcSBp/jmTeeUMws7qy78wiW8tya+q0jWO6pjCxN GHX5LnD6rDmyisGK98vZkZjspRwGKpseEXv6KaAhxPh9S89OsiuuM6e4LMAWEWFjepFTR8 NCwnErfGOCxW29NU9P8hWH+Ns7o2f5w= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=TpjbFmcB; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf28.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.183 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1742258657; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=C7kakdstnKjvLGQIhEhWpQEdZQmyKZq0R1gZch3KMP4=; b=QEn/t5t4yIQYhtRdBiGzltvC7W3Fc3S6E34QVYWQwOZJR+z3+6ejHGh+hLXcAJGJccytAU uxZ/YZd0v70BQlpJouX2GaEGyiJBpXo264Mgyvy7iuQ/AE8vhjQQhsJvi2TnVcOwV8T6FZ e52wmlOpb5crp0JhmEktznUuKD+Rjmw= Date: Tue, 18 Mar 2025 00:44:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1742258653; 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=C7kakdstnKjvLGQIhEhWpQEdZQmyKZq0R1gZch3KMP4=; b=TpjbFmcBC0KcZsaXeJOmFuFyAWlkA9Rj73jyr1MVjg3tjIaKUnbfB4EZ21KWOphqE8qKM3 EsJxpjvhGxPbMKalATQwSlz44zwQtxZZZJG9TStCQ00dgJKhLxzOC4bwwTguNvmgPPO9Jl 4Hh/ZZIPd4rxRq4pXCiTvVRUEhjNAJU= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Shakeel Butt Cc: Andrew Morton , Johannes Weiner , Michal Hocko , Muchun Song , Vlastimil Babka , Sebastian Andrzej Siewior , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Meta kernel team Subject: Re: [PATCH 2/9] memcg: decouple drain_obj_stock from local stock Message-ID: References: <20250315174930.1769599-1-shakeel.butt@linux.dev> <20250315174930.1769599-3-shakeel.butt@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250315174930.1769599-3-shakeel.butt@linux.dev> X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Queue-Id: A1D2AC0006 X-Stat-Signature: a919gk8qrnegbjk3dihbqq9nh9jeo3qr X-Rspamd-Server: rspam06 X-HE-Tag: 1742258657-982886 X-HE-Meta: U2FsdGVkX19SQTLGPl0yATlTPq2GK1spFTMQp42z6omrkzUl5/9eHMNdffltKDnfl+EbRkCP5n8GChghivSD5xEBDeB4XWw0Z7BwGNgl8FPlYRbPXAKQpSaIppNpGke7zfYx98CrqEgi8X/xOOi/KtI4OYeQbhoSHrTx/O8S3YsG5w3BMl4a5+XwFecVfeydXX2wZ6xo8c7oijCWupdMYvGlwJCVxidCMFdi2MMv7OvX7ASeLTNkkI7wfpLJDsibu9FLJUo8U2Cg4yogQPndWHNs8e+c+9fvTLAovyZYfNgm+fNz64t7SPlM/TBAijZev9kwUSI18/OtfMqATUVkoyWf6T41JjhF0x/cH9sdsz/hZKuOZIwki5AV3I0Vrw6MWuczP1y/w9UW+zdPOwieR7uXQiIWhkpc7WFChQiBCUkOuT9Ln5xbGuXItH77csw/mP32Qjo4JhAsc2M38ny/TRk8/5fnLhEyn5/bhl9derJ7R9hx9GldkRGAs8OKcdbHUaE3HFAiZCkOvys6ynQAHpsW0/Wk1t2+y8gGhObEHRnyZJ2fzoAxbRoH44KvknuIfOdreNWlzsUhpxLk4+6IGryOATCw6osGw5l8ThCjB0neWxMQoALW5dtZ+RgKiOC6vvfTKe0012Mc9PDKCjrv+U18Hmbepn4XipnLJScIT14e+eEHS85gj9geKccwrhlnGr25BeWEQMliHnUtDRSoRHi8zjFOqov6oQsXeoAe92eUj4ESIvo+IOgAAtn3QF7OOrKkukM3mKLbZN9/BTlhNrKm77DyQtGXDFugssJCA7cD+3wDUoJOxgZ+865Zl6/Hm3TUEu5n978LsXyTGzBq+4sKgB4cayglDgnb4wVyZljS9cOrYS4SATROtLWy3Geq0vvy3dMforSuYRwFVbSrOXuHuFjXiUig0IWQAkibfFO7JzizY7V66tWJ0eKPpk9gLjDa+gyg/5I6VLmPE9T vG8rKYbP TLh3PLzbFzXP5ZTYmxr+QbEvBNZgE8DJo79E2DpIMwPVUX1Pdj2RQXyL23TcIOFNDfTmNM92NOM+xtvLLXu+HbghXN6ljSBZ6JiLDPoYG6DUkE9gvMulhauQhphVdgnfLsCflL+pH5Hu1cvjy2D9Wfdm9dJjrAvlQX1WpWDpLQdRaOGZ5LoNUge5SeWNXm0A6ZejWM8YGxZbFixrI0Ywf047OqpeR5A5tmQRoNNcXzXM4Wh4cuhoJy+nYhe4yrP7iYqaahnqME/htPJI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000148, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Sat, Mar 15, 2025 at 10:49:23AM -0700, Shakeel Butt wrote: > Currently drain_obj_stock() can potentially call __refill_stock which > accesses local cpu stock and thus requires memcg stock's local_lock. > However if we look at the code paths leading to drain_obj_stock(), there > is never a good reason to refill the memcg stock at all from it. > > At the moment, drain_obj_stock can be called from reclaim, hotplug cpu > teardown, mod_objcg_state() and refill_obj_stock(). For reclaim and > hotplug there is no need to refill. For the other two paths, most > probably the newly switched objcg would be used in near future and thus > no need to refill stock with the older objcg. > > In addition, __refill_stock() from drain_obj_stock() happens on rare > cases, so performance is not really an issue. Let's just uncharge > directly instead of refill which will also decouple drain_obj_stock from > local cpu stock and local_lock requirements. > > Signed-off-by: Shakeel Butt > Acked-by: Vlastimil Babka Reviewed-by: Roman Gushchin