Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp114496lqj; Sat, 1 Jun 2024 10:07:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVK5H/GmWUtEipTBmvQBiPpNPhsNnUoCrSIfiLs7pgUcf27DCR0k9L15Se0Qx1yGbPWTZcRawTLzG7Rrzyuqw+CLoCKg5bL1NlJW2cwdg== X-Google-Smtp-Source: AGHT+IG9Zbm7gTdbHDQbinaBJ/o3Ep6iigWLDM10Mlv5X2Boc+JEBoZYtr8a9JM8JV+7dzMvaP1R X-Received: by 2002:a50:d683:0:b0:57a:2e8d:c308 with SMTP id 4fb4d7f45d1cf-57a365a1451mr2885720a12.40.1717261657656; Sat, 01 Jun 2024 10:07:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717261657; cv=pass; d=google.com; s=arc-20160816; b=nClHzf4G5W+C99LpuoC4qZEjSbajQnOXH3dznABrwy9k+8g8laL2dfnXXvA/4D05Rc QC/OCBPM3ZPH5B8ksqJWq+ILVQTcThlWR8gZ5CMuQkzNH1BrGRaHpnd8OctfdQYUpuSn jxosLnloPOEX8rwkXfRyE8mM9/c9bayXgRaV+UWX+0poiy5rHsnYZBLyU4hf95RpX0j9 eTPvPP1gOg5vfTNYWqmfRDBd/ZJpV2D2NKaHhiZiiibYt6T2/f1ueMFONAxVJdEPf3bB TE1uriv628t6k3cZxO/5B1B5YzKQ9RocbgQ01A5vcKS/liUwCgyKzaqaiGLSGfEqoUvP ulJg== 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:date:sender:dkim-signature; bh=2MXCJewXuaOb5JuphsoKQX5DhVjzwbqfBMtGCB+y5TU=; fh=7Ggw0/2Zj26SmTgLKrVq1UJuqs0RIjD30L/YRYlBqjs=; b=PHgNDSDNvZIymXjFftGhzXBO9eQoPLBoCt8Ef65WXBOkX5ltDOtK7K8zMqLMt4pFAn 4+D4foTe02UZBkV2B+/mIDOQ9N021qnm8ekvWO8wKXdswpH65+CCkonUW+eJ+Bw2TGo5 v4ZGBSOS3UCFbaFa+xwRCPvBN4oFeQfnSeWs202s9qNl9riS9hiPKxqbZtzOgSgxAnI+ CpP/3jl4BIuFt8+uqXQVBn+gr60Uz/r/EJLsWb10Xus05gJs9BkJhNh92era0AJ/Y+sU eZKMeJazXsJ0Z0WFm/s+CNDcwf4ozBYhal1CzADkwsYeI/xfR2zaLKtb7WFSuvV2Wy58 U2+A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GyoW1L1P; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-197963-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197963-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31ca5ae8si2186457a12.527.2024.06.01.10.07.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jun 2024 10:07:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-197963-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GyoW1L1P; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-197963-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197963-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 12AD41F21A41 for ; Sat, 1 Jun 2024 17:07:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 24048154BF3; Sat, 1 Jun 2024 17:07:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GyoW1L1P" Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) (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 BCC73152E05; Sat, 1 Jun 2024 17:07:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717261646; cv=none; b=gPggCnVtmwptkZbUI6b3V53SLla16snp2zybYpsQUv1voYw3URU0apvTDgT+zRtge9JMYJjzsjUkO0piy6HN29tsP2og2y+mAYNkx7K3AP59L9fyD0IsqukNLT7uO0LVk0IfRaLVV7SMjS95gs++22Mhy9gFsH0O+5Tqop1ztR8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717261646; c=relaxed/simple; bh=LZ3GDWpyd93YydDtOYzkZD4KocTVxgezuqt2lbVIKxw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iFqGK2IrQRvh8xi2j2UXYuuLxw12JBSrHZDMt0DcDCRIRGMfkuBPkUxBjJwl6mzqFSl9LCsZShm4XcIqzm10I2jOh+l3ehdGbEc4gOtLVM53AtmO+amH/ttcKe3S5dci5l4UdET0TyVY9eP01wanDkOdNirdRj6rMZGSFPKKIcY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GyoW1L1P; arc=none smtp.client-ip=209.85.215.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-6818e31e5baso2382101a12.1; Sat, 01 Jun 2024 10:07:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717261644; x=1717866444; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=2MXCJewXuaOb5JuphsoKQX5DhVjzwbqfBMtGCB+y5TU=; b=GyoW1L1PtByU8TQPiXyvbxcpBO9YLmloIQ030NvsUOTriuiKJjafu4SlD/FfUiANkB YmlPtyeIgBcVoMqsNU8DDTgBD5QDCcfwdiDzolVR7Ct1k+YCZleVJZ7jNOpn2alUVESu ZiGweV/PgdG2i0Q6qCwXK+z1Bb54I6nspZbYfrHocIvlWtqP7TkdgpbAeZH382x/Tgdu nxsHmj0QUHAbw2SbvepoqV5wYO6GBZQk0q1FYiPCJMiOIJqYIFonxEYC66a3AMzsm8ZR IQBL6jQbTDUNojiQT3TODvLQRX/b+FX14U404eBVO11rpoGSS6D4rZVQYBRp8gRBDDj6 lPRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717261644; x=1717866444; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2MXCJewXuaOb5JuphsoKQX5DhVjzwbqfBMtGCB+y5TU=; b=K7PZTdxFdI2oXwdIvj7GzUZ2YYTY+gVsPtHPoKsFjs3XISkK2hWBST9PyF3YmCBFTX 9WdjV2ccaV+0YqIOSlavN/V5VBdJxbYty9pjy22fnCLJDQ1erquxSEVoawjIa8HSNEdA Ah9end/hOQ4EMEuhGHYd8C84ktcMRvLg2CUiYqdjRMTtn3mdd6A5rCaPGjCJjN3n11jZ eJRPr1n0hViaEdou3U4+/+9yH+hbJMdoSOlf6cxhTO7JKzrOUBJnD/IuuPfRAbNKeCdb 4w4u0lcv9k9IWWe4ZYj8uSb1lDkfQX5Ui4O6OQT6LXZTGlv++u/2Czrnwzg6ysfbRZsh 1tuQ== X-Forwarded-Encrypted: i=1; AJvYcCX/0ASQrWOd4r2IWSIxxUvg3jgINVRabVzsBRJAer73mdjgB5QDba1bY/geEvvC5RCJGZMTXkPDW6+KrbXQ/L3mADbXjLWaf7j3EWfuw6yRbcA/cMZnB8Q44cdeCa6V2+NaEuQn5w== X-Gm-Message-State: AOJu0YzB0vGy0AiYDWNNy2k4tcb/86w7PfxUDLYTk7UV5uQEJ5vH6EPA U5J2yAcA9xpuX7KZcmK5/Npn+Nl8uhdGEkeCph6Ift6zMkwoVGph X-Received: by 2002:a17:903:40c1:b0:1f3:2d51:17a with SMTP id d9443c01a7336-1f636ffa8a8mr61979185ad.18.1717261643904; Sat, 01 Jun 2024 10:07:23 -0700 (PDT) Received: from localhost (dhcp-141-239-159-203.hawaiiantel.net. [141.239.159.203]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f665929689sm2114745ad.151.2024.06.01.10.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jun 2024 10:07:23 -0700 (PDT) Sender: Tejun Heo Date: Sat, 1 Jun 2024 07:07:22 -1000 From: Tejun Heo To: Waiman Long Cc: Xiu Jianfeng , lizefan.x@bytedance.com, hannes@cmpxchg.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH -next] cgroup/cpuset: Reduce the lock protecting CS_SCHED_LOAD_BALANCE Message-ID: References: <20240525094648.1585086-1-xiujianfeng@huawei.com> 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: On Fri, May 31, 2024 at 04:07:32PM -0400, Waiman Long wrote: > > On 5/26/24 14:35, Tejun Heo wrote: > > On Sat, May 25, 2024 at 09:46:48AM +0000, Xiu Jianfeng wrote: > > > In the cpuset_css_online(), clearing the CS_SCHED_LOAD_BALANCE bit > > > of cs->flags is guarded by callback_lock and cpuset_mutex. There is > > > no problem with itself, because it is consistent with the description > > > of there two global lock at the beginning of this file. However, since > > > the operation of checking, setting and clearing the flag bit is atomic, > > > protection of callback_lock is unnecessary here, see CS_SPREAD_*. so > > > to make it more consistent with the other code, move the operation > > > outside the critical section of callback_lock. > > > > > > No functional changes intended. > > > > > > Signed-off-by: Xiu Jianfeng > > > --- > > > kernel/cgroup/cpuset.c | 14 ++++++-------- > > > 1 file changed, 6 insertions(+), 8 deletions(-) > > > > > > diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c > > > index f9d2a3487645..315f8cbd6d35 100644 > > > --- a/kernel/cgroup/cpuset.c > > > +++ b/kernel/cgroup/cpuset.c > > > @@ -4038,6 +4038,12 @@ static int cpuset_css_online(struct cgroup_subsys_state *css) > > > set_bit(CS_SPREAD_PAGE, &cs->flags); > > > if (is_spread_slab(parent)) > > > set_bit(CS_SPREAD_SLAB, &cs->flags); > > > + /* > > > + * For v2, clear CS_SCHED_LOAD_BALANCE if parent is isolated > > > + */ > > > + if (cgroup_subsys_on_dfl(cpuset_cgrp_subsys) && > > > + !is_sched_load_balance(parent)) > > > + clear_bit(CS_SCHED_LOAD_BALANCE, &cs->flags); > > The code looks weird to me. It's doing the same thing under the > > is_in_v2_mode() block and the cgroup_subsys_on_dfl() block and the former is > > also run when the latter condition is true. Looks like we can get rid of the > > latter block? Waiman? > > Sorry for the late reply. > > The handling of the CS_SCHED_LOAD_BALANCE flag is different between v1 and > v2. For v1, CS_SCHED_LOAD_BALANCE is default to ON unless it is explicitly > turned off by writing to cpuset.sched_load_balance. For v2, the state will > follow its parent when a new cpuset is brought online. Since is_in_v2_mode() > can be on with cgroup v1, we can't group the two together. > > I agree that we don't need to protect the clearing of CS_SCHED_LOAD_BALANCE > with the callback lock. So I don't have objection to this patch. > > Acked-by: Waiman Long Applied to cgroup/for-6.11. Thanks. -- tejun