Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3098761pxp; Tue, 8 Mar 2022 07:42:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJxBAUJXy/hT7KqVn6EBLsvS3hziUmQGeTMWltsriZC+s29NF+nslv7NAiv0wIt5gspqfNYY X-Received: by 2002:a65:6390:0:b0:376:7f43:e9a1 with SMTP id h16-20020a656390000000b003767f43e9a1mr14558024pgv.480.1646754151839; Tue, 08 Mar 2022 07:42:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646754151; cv=none; d=google.com; s=arc-20160816; b=gHr5AQ/4clgHm4toy4irRNScyMnMNmJc3D2M3YOVHNp6cB87c21fchlogT5VA8BKcI srhrxfcEE4mLc2UuM15yNnCYyULQHPDcHHWBl7yCXN0KA77Vth4dcs4jkIewvAbh5QDo op8kYMWN4J89RQGAk+l3EQyT1/hh5+ElZTG+n8Kw25Hru7jot1FS2kVg0zbMP3QaCEnB YckBPT0i1s5D3gDWUDdznno+cXzTnjOo5AUsvf2A4XujsZP0jNarqp8sfxnVlQBkst8e 15C0eu1Sn5Iy8kpP68Fovtn2+xIRYl22VWC2vKM/LGwLt3znDAH+E2AWm62zY0D1gmot 5z6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=BxPH7nt5TPZXBWMbjXfb0ej096MEr0JkhBc0/u6GevU=; b=L+ohmOiR/X3g/yDeirlKr+xk8f3YAbk1OHk6JGST7sLWL8Ovn8KHq+femPQu34e19I bZ82v6LzCJhVZPmXThlurF4dWT4xVlBMfTcruE1xz8OZnHYEW5p/k0D6jzqKZkl2VGkH 3b6z1NPQfq8AFuAkH1Aiak0WyDOrSg2jlNi2C0Rv55dR2GZq8HJ1HoOtET1iUmAGvSfc Wydx5UqaDHpPoFSsugwRyDJUYOViFLgVWomdRc/hFfp63bLohJQiU7GVVqRu7pB3KTnx xVurRAl9+Qp8LRH9QkgA1ANJoIpcioP9EByz1C/eqfIGUSiii8JQIgW0v5gIXVv25cGm SVQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=cyt46GYa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i2-20020a17090ac40200b001bd14e030a2si2220108pjt.122.2022.03.08.07.42.13; Tue, 08 Mar 2022 07:42:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=cyt46GYa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242335AbiCHPNe (ORCPT + 99 others); Tue, 8 Mar 2022 10:13:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347769AbiCHPNc (ORCPT ); Tue, 8 Mar 2022 10:13:32 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C53710C5; Tue, 8 Mar 2022 07:12:35 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CB33C1F388; Tue, 8 Mar 2022 15:12:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1646752353; h=from:from:reply-to: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=BxPH7nt5TPZXBWMbjXfb0ej096MEr0JkhBc0/u6GevU=; b=cyt46GYaOI6J7Z5rYcz5ScPHcC9keNvMgOAj0NaXjqckcWfllCAin9wTIhR02TqS2nxtsd dnCAY+gdaWyCM66XkihTDE6VCGH5GEJW6udz+/0NFmhNEexZhmlmgIG7kq6gN7ERVqqVEh hCHtBNTUjVc18hnMj4rvB9LLpTzKwH0= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A53AC13CE9; Tue, 8 Mar 2022 15:12:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 4/fYJ2FyJ2K8TwAAMHmgww (envelope-from ); Tue, 08 Mar 2022 15:12:33 +0000 Date: Tue, 8 Mar 2022 16:12:32 +0100 From: Michal =?iso-8859-1?Q?Koutn=FD?= To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Zhao Gongyi , Zhang Qiao , Waiman Long , Tejun Heo , Juri Lelli Subject: Re: [PATCH 4.19 01/34] cgroup/cpuset: Fix a race between cpuset_attach() and cpu hotplug Message-ID: <20220308151232.GA21752@blackbody.suse.cz> References: <20220228172207.090703467@linuxfoundation.org> <20220228172208.566431934@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220228172208.566431934@linuxfoundation.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello. On Mon, Feb 28, 2022 at 06:24:07PM +0100, Greg Kroah-Hartman wrote: > [...] > cpuset_attach() cpu hotplug > --------------------------- ---------------------- > down_write(cpuset_rwsem) > guarantee_online_cpus() // (load cpus_attach) > sched_cpu_deactivate > set_cpu_active() > // will change cpu_active_mask > set_cpus_allowed_ptr(cpus_attach) > __set_cpus_allowed_ptr_locked() > // (if the intersection of cpus_attach and > cpu_active_mask is empty, will return -EINVAL) > up_write(cpuset_rwsem) > [...] > --- a/kernel/cgroup/cpuset.c > +++ b/kernel/cgroup/cpuset.c > @@ -1528,6 +1528,7 @@ static void cpuset_attach(struct cgroup_ > cgroup_taskset_first(tset, &css); > cs = css_cs(css); > > + cpus_read_lock(); > mutex_lock(&cpuset_mutex); This backport (and possible older kernels) looks suspicious since it comes before commit d74b27d63a8b ("cgroup/cpuset: Change cpuset_rwsem and hotplug lock order") v5.4-rc1~176^2~30 when the locking order was: cpuset lock, cpus lock. At the same time it also comes before commit 710da3c8ea7d ("sched/core: Prevent race condition between cpuset and __sched_setscheduler()") v5.4-rc1~176^2~27 when neither __sched_setscheduler() cared and this race is similar. (The swapped locking may still conflict with rebuild_sched_domains() before d74b27d63a8b.) Michal