From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 ADE552BEFFE for ; Sun, 21 Jun 2026 03:24:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782012268; cv=none; b=iLBN1eIM7VlU8YVXRGn3FUdQ16FcxXpRuVnz/6PQJKBys1giUtUABXMKEO+GMltkUN1hFpejKPWuf3t2+UWehyYUJvC7/1PvgjPU4yu6KImFUqU9p1YyJgIFB2WVK9xAdm8Xph+8hBZX7tq6tJ+x9jaTZlUxwW+vOEitRRAp0VQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782012268; c=relaxed/simple; bh=Y0Ba6yPSCo9zQjmVk6P93mv40CSzFhFf9lgURZqXbgE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=u64f3KK6iJq0sintC7Dgq1RJsvMvgiY6mKq58lU015Vdb9oGgjRoY416u5m/iwPl3UwfVvDubY9CJKnbNyM/oOoykAK6yh0MMXHYWP8evoIKcib3uZuR2i3bNGEbQAe8dT4TUgmXX5ZGbw9Mt3oROWsJvBs8+cOABnq93cJyPCo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=TVLEYyap; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TVLEYyap" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782012266; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4Yu2mki38BefPDLre6bXeAKMaOu1RLSJX8hzP70eax4=; b=TVLEYyapsapO5v1tIDtti/dilMJJ5R+gs3XsFWwXHJmnTpGANj7zNRUDUZVyWHvwrDgGAF arnY8lz6KIydXf3b+fLox+mcV3UOHviooaVkB6DMdS75T8U0mn/qj2KK1WjtT8B7XJhWuZ IQgBn7l24rF1zdfS9oSXeI1801jKHd4= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-537-HmnhANAkPfSLuV-PbR185Q-1; Sat, 20 Jun 2026 23:24:21 -0400 X-MC-Unique: HmnhANAkPfSLuV-PbR185Q-1 X-Mimecast-MFC-AGG-ID: HmnhANAkPfSLuV-PbR185Q_1782012259 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 448821956060; Sun, 21 Jun 2026 03:24:18 +0000 (UTC) Received: from [10.22.88.8] (unknown [10.22.88.8]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AE5FA1686; Sun, 21 Jun 2026 03:24:14 +0000 (UTC) Message-ID: <9d8b650d-6faa-425a-8db7-1e206cb25158@redhat.com> Date: Sat, 20 Jun 2026 23:24:13 -0400 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] cgroup/cpuset: rebind mm mempolicy to effective_mems, not mems_allowed To: "David Hildenbrand (Arm)" , Gregory Price Cc: Farhad Alemi , Andrew Morton , Farhad Alemi , Yury Norov , Joshua Hahn , Zi Yan , Matthew Brost , Rakie Kim , Byungchul Park , Ying Huang , Alistair Popple , Rasmus Villemoes , linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, stable@vger.kernel.org References: <8d3b4561-92cd-4ebc-8462-5fb0fd659e8a@kernel.org> <70f486ce-5ef6-4d72-8cc3-7086f4eea930@redhat.com> <51eafe6c-6622-479b-b391-6d3ff9350e75@kernel.org> <38578aea-61c3-4328-aee9-8e7421672647@kernel.org> Content-Language: en-US From: Waiman Long In-Reply-To: <38578aea-61c3-4328-aee9-8e7421672647@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 On 6/18/26 4:41 AM, David Hildenbrand (Arm) wrote: > On 6/16/26 17:23, Waiman Long wrote: >> On 6/16/26 2:59 AM, David Hildenbrand (Arm) wrote: >>> On 6/16/26 05:43, Waiman Long wrote: >>>> BTW, I still prefer the v2 patch. If it is decided we should use the >>>> guarantee_online_mems() value instead, it will have to be a separate patch with >>>> changes in the relevant documentation like Documentation/admin-guide/cgroup-v1/ >>>> cpuset.rst. >>> newmems is "obviously" correct, so I really don't see why we should add >>> something that needs half a page of text to explain why it is fine -- if newmems >>> just does the trick? >>> >>> Please enlighten me. >> Yes, taking newmems is a reasonable choice and there are pros and cons with each >> options. My focus is more on not changing how v1 cpuset behaves as it is well >> defined in the v1 cpusets.rst file: >> >>     Requests by a task, using the sched_setaffinity(2) system call to >>     include CPUs in its CPU affinity mask, and using the mbind(2) and >>     set_mempolicy(2) system calls to include Memory Nodes in its memory >>     policy, are both filtered through that task's cpuset, filtering out any >>     CPUs or Memory Nodes not in that cpuset.  The scheduler will not >>     schedule a task on a CPU that is not allowed in its cpus_allowed >>     vector, and the kernel page allocator will not allocate a page on a >>     node that is not allowed in the requesting task's mems_allowed vector. >> >> v2, OTOH, is more vague as to what setting cpuset.mems will mean and we >> generally follow what v1 is doing, but we have more leeway of what we can do. >> >> Using newmems will make the above text not totally correct. At least the offline >> memory nodes will be filtered out which will not be utilized by the task when >> the offline node becomes online. That is why I am saying that we will have to >> correct the documentation if we want to make this change. > So IIUC: > > diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c > index 1335e437098e..cdfc615f35a5 100644 > --- a/kernel/cgroup/cpuset.c > +++ b/kernel/cgroup/cpuset.c > @@ -2645,7 +2645,13 @@ void cpuset_update_tasks_nodemask(struct cpuset *cs) > > migrate = is_memory_migrate(cs); > > - mpol_rebind_mm(mm, &cs->mems_allowed); > + /* > + * For v1 we can have empty effective_mems, but we cannot > + * attach any tasks (see cpuset_can_attach_check()). For v2, > + * it's guaranteed to not be empty. > + */ > + VM_WARN_ON_ONCE(nodes_empty(cs->effective_mems)); > + mpol_rebind_mm(mm, &cs->effective_mems); > if (migrate) > cpuset_migrate_mm(mm, &cs->old_mems_allowed, &newmems); > else That is true, but I don't think we need a VM_WARN_ON_ONCE() here. Cheers, Longman >