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.133.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 C9EAD281525 for ; Mon, 2 Feb 2026 18:21:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770056510; cv=none; b=HIzwz0GZ/GDMAyX3uATAF2yV8F296K28kQA7U5wEX1E7blf9AOI7pyt01fmBVUtAPCPNOtRCPWQQBp7DOCWcMIY0BCpUTo2r7+nTaGDkaMZ+sj2boH7TbBdDVtt7awVras6l0QdtamSxJzt4hErRBiDvq8JTSof0DF0Hpg97RG4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770056510; c=relaxed/simple; bh=ZgFPpzWS2e4pSmnR8N9TBShnHKYDmbpBdWZEJxThLWI=; h=From:Message-ID:Date:MIME-Version:Subject:To:Cc:References: In-Reply-To:Content-Type; b=JX2+I7sdY8B4IL82tsRM39HfF91o9xLuNqmN9DGqesf77M53DaHwzoECWLMECW/XH+uJ00xyi3v50wSCZGj4M4ttR6USgqLoTfo6Hwu4E3ce6vVSLehHkg/F9Zjrw9wzccEO+BaR95Ql+BWfS1lSFqcajIfibamMXn8jh+r4QgI= 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=Gw+Ln7ht; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=MW4uBhmr; arc=none smtp.client-ip=170.10.133.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="Gw+Ln7ht"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="MW4uBhmr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770056507; 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=mJfpaXz7AFF7IJW/W7RDCIALtDcgndOMABwDoErkBSU=; b=Gw+Ln7htsdEGetNh+JUpA4stq+Y3jt4Q5xhlAzlox1bhKVX2M5q5fJ5Oh4tQ5TokhvcwHV uOResSQYqt06OgB402pRGyl7Rrxhnm3KjefQrydCc1liQjqQyOnccrlVACn0X0xrQnGCfi pUwt2Bbki8bFohxuscZtLuaSyQMkddQ= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-408-gxrTgwNqNkGOizcBw8ouxA-1; Mon, 02 Feb 2026 13:21:46 -0500 X-MC-Unique: gxrTgwNqNkGOizcBw8ouxA-1 X-Mimecast-MFC-AGG-ID: gxrTgwNqNkGOizcBw8ouxA_1770056505 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-5019f8a18cdso158771221cf.2 for ; Mon, 02 Feb 2026 10:21:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1770056505; x=1770661305; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:user-agent:mime-version:date:message-id:from:from:to :cc:subject:date:message-id:reply-to; bh=mJfpaXz7AFF7IJW/W7RDCIALtDcgndOMABwDoErkBSU=; b=MW4uBhmrw3fZt/ZtudRo2Tx0kAoKg1OuZ3O/19wOzfXpsf4pVpHZ1LoztO7PxgzXTt vlUM+qIEH3yMvErA8/b+KVrHCh6ZJD9cTeCMJtspQ72DUZR9p3b1EDB6LKG4GZboC8fS O/h6wUAOptPxNaGdCEcIglnM3psWbI2bM0M/BqbRmSPWwtMA8PMc2QkOxFJwOsX9Tx0q FMty19Hx7jwOlBKRVxA9RULCNa7vF0GoTW6jIHxG1ys/uq2b9SNuewl9PiaxT4k/6ayn T2RrReGzHf85mVxOr4bqbzen2gHEerBAx5r0HrynZniVB7ryOj3KhpIxd2LQFv8VdADz WBqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770056505; x=1770661305; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:user-agent:mime-version:date:message-id:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mJfpaXz7AFF7IJW/W7RDCIALtDcgndOMABwDoErkBSU=; b=hisyyB38Ugyg8BWXb9Rs3AWitaj+4wrRwFmxuQjyzRloorDyaaHgy2nv8a5FcfbaSJ 1/R2IJsgCKgFu5ZMvyhuqpt3ihvR7Z+CkmxDFnFVXAcubB40mA4XydFxkdIpthAwYM6j 7OlHRBNexJLGdKkEadah+DS7NHSIgTAi3GdIUAWpvAxdSStvj3ICnVj6MCA0OLQIv5VI FaAx12Tkf3BFrGPdnBCIe05nhgotf/38rDxe+ldVSUiUsaSgBWe5lL49BefIX7ly8mWt +Rb3VQC7iQpotmiPrUXccTQjd29YU8zzNAaOqsI+OqP94iFHBPe5JwBroFKD/7Cg6hfa mQAA== X-Forwarded-Encrypted: i=1; AJvYcCV+gC90xCS3cRSwuSRxvlNIw/2VNSiGfo5J4wDQe+y7qjcq1gvrtA7TuWoKZOG103Ww7MJup0muJea29Q8=@vger.kernel.org X-Gm-Message-State: AOJu0Yzx/DnNgaX5Cm52ODHneWO1SJq9O+zYBzyPvd3DTeTKr9/8iPAl 1h1ItY2VCIltiHALmcQTAn5OGsbmrRtRH5l/eDBb0XDrzkXxjCmbqHGjWFmZc6AJUbPgapeEJNp mcFb5v7QjX0gWezsVYL+dQs1yQkWfMA/Li4Mr/3trnfOEh8/79gMNoQTz5YJldR8UwA== X-Gm-Gg: AZuq6aJ3UCt8kv4UCEcLbHYzn8b7/O2Gz7RQ+4mhwPVv9F/8pwLcjWdHTmPNH/d8E2g EbEF0h1dqH7xtTPuyt7qUeliqlBqv8rDoi82lVU5phvS7g4aKbvPQPnN1N4dVMRFWDqwtbF28Wh 0NZrFgFhFjVAh4xj/Xp9V5o/A7lHdzEjR7iv0i9Wuo5COhO5sgefaZ0lqtwi+VMka4E3sPTvwxO 4Y2vqMoa8ymv+uEB06r0t0f95F9gG/bbhYb1CnUS99wo6yFmilre2T8qtAyHBfzR0S5SLsF6Am1 jqeolttYpPURgnlQN+r7ilenbu9jeVxz3fNvNx+PmpC/oiL5dc5W0xXIVBK/TZUyVY68FyVzd5W J5+k4BM7juJqpbhDFb3jdSFJexMwohWvoQOBMSJyS98Iklq992aZiTL3v X-Received: by 2002:ac8:580d:0:b0:501:40af:96cb with SMTP id d75a77b69052e-505d229cca2mr164744311cf.58.1770056505601; Mon, 02 Feb 2026 10:21:45 -0800 (PST) X-Received: by 2002:ac8:580d:0:b0:501:40af:96cb with SMTP id d75a77b69052e-505d229cca2mr164743941cf.58.1770056505216; Mon, 02 Feb 2026 10:21:45 -0800 (PST) Received: from ?IPV6:2601:188:c102:b180:1f8b:71d0:77b1:1f6e? ([2601:188:c102:b180:1f8b:71d0:77b1:1f6e]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50337cbdc24sm114980071cf.32.2026.02.02.10.21.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Feb 2026 10:21:44 -0800 (PST) From: Waiman Long X-Google-Original-From: Waiman Long Message-ID: Date: Mon, 2 Feb 2026 13:21:43 -0500 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/for-next v2 1/2] cgroup/cpuset: Defer housekeeping_update() call from CPU hotplug to workqueue To: Peter Zijlstra Cc: Chen Ridong , Tejun Heo , Johannes Weiner , =?UTF-8?Q?Michal_Koutn=C3=BD?= , Ingo Molnar , Juri Lelli , Vincent Guittot , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Shuah Khan , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org References: <20260130154254.1422113-1-longman@redhat.com> <20260130154254.1422113-2-longman@redhat.com> <20260202130526.GE1395266@noisy.programming.kicks-ass.net> Content-Language: en-US In-Reply-To: <20260202130526.GE1395266@noisy.programming.kicks-ass.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2/2/26 8:05 AM, Peter Zijlstra wrote: > On Fri, Jan 30, 2026 at 10:42:53AM -0500, Waiman Long wrote: > >> +/* Both cpuset_mutex and cpus_read_locked acquired */ >> +static bool cpuset_locked; >> + >> /* >> * A flag to force sched domain rebuild at the end of an operation. >> * It can be set in >> @@ -285,10 +288,12 @@ void cpuset_full_lock(void) >> { >> cpus_read_lock(); >> mutex_lock(&cpuset_mutex); >> + cpuset_locked = true; >> } >> >> void cpuset_full_unlock(void) >> { >> + cpuset_locked = false; >> mutex_unlock(&cpuset_mutex); >> cpus_read_unlock(); >> } >> @@ -1293,14 +1308,30 @@ static bool prstate_housekeeping_conflict(int prstate, struct cpumask *new_cpus) >> */ >> static void update_isolation_cpumasks(void) >> { >> - int ret; >> + static DECLARE_WORK(isolcpus_work, isolcpus_workfn); >> >> if (!isolated_cpus_updating) >> return; >> >> - ret = housekeeping_update(isolated_cpus); >> - WARN_ON_ONCE(ret < 0); >> + /* >> + * This function can be reached either directly from regular cpuset >> + * control file write (cpuset_locked) or via hotplug (cpus_write_lock >> + * && cpuset_mutex held). In the later case, we defer the >> + * housekeeping_update() call to the system_unbound_wq to avoid the >> + * possibility of deadlock. This also means that there will be a short >> + * period of time where HK_TYPE_DOMAIN housekeeping cpumask will lag >> + * behind isolated_cpus. >> + */ >> + if (!cpuset_locked) { > I agree with Chen that this is bloody terrible. > > At the very least this should have: > > lockdep_assert_held(&cpuset_mutex); > > But ideally you'd do patches against this and tip/locking/core that add > proper __guarded_by() annotations to this. Yes, I am going to remove cpuset_locked in the next version. As for __guarded_by() annotation, I need to set up a clang environment that I can use to test it before I will work on that. I usually just use gcc for my compilation need. Cheers, Longman