Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3052623lqo; Tue, 14 May 2024 19:45:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXJxYCCsLLDrH0Jcy+Ch9LWri1eTTZ1PyTCXGVOpsuu1N8ZRfEWPSxBFxHrhDNnXprozdo4eZL9UZ7SSztITW14zlYzEzMsW/yDv00PGg== X-Google-Smtp-Source: AGHT+IGpkSKvSLSOjvmDMp3UF6BXMXof+qbVRExPhEBocRP9QcLvETx/4ISoDKQLIm7W5AttmStt X-Received: by 2002:ac8:580c:0:b0:43a:be1d:ff11 with SMTP id d75a77b69052e-43dfdabd5a6mr135551171cf.3.1715741118818; Tue, 14 May 2024 19:45:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715741118; cv=pass; d=google.com; s=arc-20160816; b=w5AuSvk1SIVIkBCdE9f1dTU2VjsUvo/T3oSKUtmdYqyj4gTpPrHKERq6F8o+ivL9ax OucfClQIn3TQYJjtPV0rvOLnKq5lRcqeXoikddUADIhT1ec4LQDaSmOpDKrz79PM1+8x nFfbJsmMgGevh5Vqtq1Jy1WcdUwvg2YvjvX9+Gmne49p0hLEziGZsyVXtsri3Bd1N+eJ 3uxcbK3c7iXtgbrBA7EGzxXH9k7nHjaxo9CykJN5zGqjMhpOgBNXMbzH3Mxp/SbTkA7i fev/V9w5uw9I1/4Ad6vGaXpIR1rMaXF5MvEUyLrkCIiHQjWppnOdDBvBPU7OKTqkCAnF TFFQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=a8EMbPNbI6tRHdtjC0S1Hs0q8JJEy2AFPIjYs7OQ6e4=; fh=uEpp58aX4v2HXbDJbq05LBbyUPDiBYVghITlypUBHZY=; b=LN4uf5pGLjOFRBGSvXcwUVgo8lR1KM3ttGoZ4iSgl6j5pxQCCYmAKS6OEovi/PWRFZ 2H6StAujl4gwwiMeY4U6LTXLeHohL6B9POaJvLAZpXEFdifbuFNVCRAde0ewE53BAvb4 0Qq+0yCCZLHEBH3BdFbZpX4qoRlTIHrW51PkXdmCU+GSOka00oNwQD8+0ShIQghLD7OB xOvPPYVx8rk/HHOebw5mIXGDdt56rAgWN1vFe8Xm8dxJinl8w37S8d04ihtce2etCh6V zvkNrq8fx5FgUR3/Do09A0aCpLm/MWHg4WP6Xo+OG5GdLqulFPP8mCbDmJct0gfR93Xk yV7g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-179358-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179358-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43df5499665si134584381cf.132.2024.05.14.19.45.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 19:45:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179358-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-179358-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179358-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 8B3021C21222 for ; Wed, 15 May 2024 02:45:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5552537142; Wed, 15 May 2024 02:45:11 +0000 (UTC) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (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 BD9478F5A; Wed, 15 May 2024 02:45:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715741110; cv=none; b=oo4eGMP8PzNQhgvCMCLC+YKb+dkadCPwXe/BNHrijL56meZl8cj/o8chtEBUDiFhdA2iX12yZwkU7DwLkx5IilJzL5GF5Ct8LfwjNW/hqn6wKuMT5RgYtTkPIagGPdlhLR3tv4xvfwdONxe0dImo/F9a96sLFNngQEdnoBpovB0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715741110; c=relaxed/simple; bh=y5b1xG04vn1CcIUIecHfF8Tcjak6yElJQa34HoZDmyc=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=UqO5xqUdcm8BXx7xRsuTrVp6aK1vB3WF3xc3ACLlQwy/+oa4rD2gwLWMDPsFFfS3Z99yl5sEWtXgMXFQs6a3MO1U1twtUnqsFL9i67Su7CdzA7GqhEEe5VjaLKIKdHfO0ApYHWmYVOJjE1dMfSG3aXLsAuzU6nTaMSQ+SDa5/EA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4VfHYD3chGzvYjJ; Wed, 15 May 2024 10:41:36 +0800 (CST) Received: from dggpeml500023.china.huawei.com (unknown [7.185.36.114]) by mail.maildlp.com (Postfix) with ESMTPS id 2A074180085; Wed, 15 May 2024 10:45:05 +0800 (CST) Received: from [10.67.110.112] (10.67.110.112) by dggpeml500023.china.huawei.com (7.185.36.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 15 May 2024 10:45:04 +0800 Message-ID: <29aae825-6a1c-1935-a50f-d824c308c4c9@huawei.com> Date: Wed, 15 May 2024 10:45:04 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH -next] memcg: don't handle event_list for v2 when offlining To: Michal Hocko CC: , , , , , , , References: <20240514131106.1326323-1-xiujianfeng@huawei.com> Content-Language: en-US From: xiujianfeng In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500023.china.huawei.com (7.185.36.114) On 2024/5/14 22:09, Michal Hocko wrote: > On Tue 14-05-24 13:11:06, Xiu Jianfeng wrote: >> The event_list for memcg is only valid for v1 and not used for v2, >> so it's unnessesary to handle event_list for v2. > > You are right but the code as is works just fine. The list will be > empty. It is true that we do not need to take event_list_lock lock but > nobody should be using this lock anyway. Also the offline callback is > not particularly hot path. So why do we want to change the code? > Actually, I don’t quite agree, but I don't insist on this patch. Thanks for your feedback. >> >> Signed-off-by: Xiu Jianfeng >> --- >> mm/memcontrol.c | 12 +++++++----- >> 1 file changed, 7 insertions(+), 5 deletions(-) >> >> diff --git a/mm/memcontrol.c b/mm/memcontrol.c >> index d127c9c5fabf..4254f9cd05f4 100644 >> --- a/mm/memcontrol.c >> +++ b/mm/memcontrol.c >> @@ -5881,12 +5881,14 @@ static void mem_cgroup_css_offline(struct cgroup_subsys_state *css) >> * Notify userspace about cgroup removing only after rmdir of cgroup >> * directory to avoid race between userspace and kernelspace. >> */ >> - spin_lock_irq(&memcg->event_list_lock); >> - list_for_each_entry_safe(event, tmp, &memcg->event_list, list) { >> - list_del_init(&event->list); >> - schedule_work(&event->remove); >> + if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) { >> + spin_lock_irq(&memcg->event_list_lock); >> + list_for_each_entry_safe(event, tmp, &memcg->event_list, list) { >> + list_del_init(&event->list); >> + schedule_work(&event->remove); >> + } >> + spin_unlock_irq(&memcg->event_list_lock); >> } >> - spin_unlock_irq(&memcg->event_list_lock); >> >> page_counter_set_min(&memcg->memory, 0); >> page_counter_set_low(&memcg->memory, 0); >> -- >> 2.34.1 >