Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4542908rwl; Mon, 3 Apr 2023 06:32:03 -0700 (PDT) X-Google-Smtp-Source: AKy350adWqiA1f9iPBGQi/YXaW50R86RZfCuAMyIQYxErKz4x4WjuwnlcTYJkx2RYfid+GKQTDGJ X-Received: by 2002:a17:907:a64a:b0:92e:e9c2:7b9c with SMTP id vu10-20020a170907a64a00b0092ee9c27b9cmr35920327ejc.77.1680528722926; Mon, 03 Apr 2023 06:32:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680528722; cv=none; d=google.com; s=arc-20160816; b=Xd4RnF5ShtY1Ftp7Pi56k9eeZevU8hm54ZVX/UFRCL+FsvQV6bnItE2dNxZCsJ8HZL Wi5iQOIIpQ/BtdH14u/JLjfMpxAF1NfSTf0Qm+Lwk/HzCNeiOxL5vYrF75wRYAMM+KI7 HhHfc2m9mr4H/axfHkV6l7mRrYWuwFfP2dwgSUvous5c6EikxIlwxClYB83uPH5eCsOz Qg5RDhVyH53EyPq3M352nPJTYPSs/smcpk5OnSsFdCFAleS+3P5vTJ1KustN1ZqNQRQ9 MmRza/YODojTcV9jr0aPF0VvQKQAsoYTGWKu0hfgP3PEolF52oA3EHmp6WzGMxAy9lxw hKqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=oFE+mJfqTPvmWZksLhnoNTPkTakWb9hjaUP24sOld6E=; b=yUSbqjZybVqJmkq/r2TQieJbSrWHOFwQVlvzyPbYfsirQvMbRUnk2KFmbatU8kyefa +VcGSwIbgrFNLYZkRZeTGPu6afBFNPEDUJ+OuniIKmgIWT5N4LMsDG8zhwMpLGl/P/5H wLpDN0VfHuQXjN9SEb2Xd4Wmq6Y/0LCOvi4Wx1ywWZYxY5q6uwWCfpXTZofms/5+XpD0 2IDfhxCMJ2mZJrb7oHKx6DERXVt7ABSRQ733J6OnUIjJbkyzk/W6MQ3luJUlZhHLt8Qm Ae1vcdoZbGyuk9JXsKRK/Y8QlX7URXpyoGOPvyyY/7UAewgXAyEAZvMqCjqcyQrCxCGK aiCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Y4heVgHx; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ay14-20020a170906d28e00b00947bdd3a091si613975ejb.384.2023.04.03.06.31.13; Mon, 03 Apr 2023 06:32:02 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=Y4heVgHx; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232603AbjDCNa4 (ORCPT + 99 others); Mon, 3 Apr 2023 09:30:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231816AbjDCNaz (ORCPT ); Mon, 3 Apr 2023 09:30:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56B42A4; Mon, 3 Apr 2023 06:30:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E4B0661B44; Mon, 3 Apr 2023 13:30:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD924C433D2; Mon, 3 Apr 2023 13:30:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1680528653; bh=gkl9GJzTmsB5rcAcfYLEeF2AGlRRvqNK46WjzttEC+Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Y4heVgHxnHHk+SR9DYW1yfI1s8uJMUtEql8IsErHkwN1QcZvm9puL+Hl/9ZV53BUk cE3mH8laTXfuRBwINC4vjQHrNcbwzi6IFO+1bmRSNc9blc9TsGYZRknRJj1g+VuEtf V2/EXiWZVsxSsaQyDDBHAl+1vxspuWjraNrsv5Qs= Date: Mon, 3 Apr 2023 15:30:51 +0200 From: Greg KH To: Cai Xinchen Cc: longman@redhat.com, lizefan.x@bytedance.com, tj@kernel.org, hannes@cmpxchg.org, sashal@kernel.org, mkoutny@suse.com, zhangqiao22@huawei.com, juri.lelli@redhat.com, penguin-kernel@i-love.sakura.ne.jp, stable@vger.kernel.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 4.19 0/3] Backport patches to fix threadgroup_rwsem <-> cpus_read_lock() deadlock Message-ID: <2023040343-dingbat-undermine-3b2d@gregkh> References: <20230320011507.129441-1-caixinchen1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230320011507.129441-1-caixinchen1@huawei.com> X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 On Mon, Mar 20, 2023 at 01:15:04AM +0000, Cai Xinchen wrote: > I am very sorry. My gcc version is 7.5 and it does not report error. > > We have a deadlock problem which can be solved by commit 4f7e7236435ca > ("cgroup: Fix threadgroup_rwsem <-> cpus_read_lock() deadlock"). > However, it makes lock order of cpus_read_lock and cpuset_mutex > wrong in v4.19. The call sequence is as follows: > cgroup_procs_write() > cgroup_procs_write_start() > get_online_cpus(); // cpus_read_lock() > percpu_down_write(&cgroup_threadgroup_rwsem) > cgroup_attach_task > cgroup_migrate > cgroup_migrate_execute > ss->attach (cpust_attach) > mutex_lock(&cpuset_mutex) > it seems hard to make cpus_read_lock is locked before > cgroup_threadgroup_rwsem and cpuset_mutex is locked before > cpus_read_lock unless backport the commit d74b27d63a8beb > ("cgroup/cpuset: Change cpuset_rwsem and hotplug lock order") > > Changes in v2: > * Add #include in kernel/cgroup/cgroup.c to > avoid some compile error. > * Exchange get_online_cpus() location in cpuset_attach to > keep cpu_hotplug_lock->cpuset_mutex order, although it will > be remove by ("cgroup: Fix threadgroup_rwsem <-> > cpus_read_lock() deadlock") > > Juri Lelli (1): > cgroup/cpuset: Change cpuset_rwsem and hotplug lock order > > Tejun Heo (1): > cgroup: Fix threadgroup_rwsem <-> cpus_read_lock() deadlock > > Tetsuo Handa (1): > cgroup: Add missing cpus_read_lock() to cgroup_attach_task_all() > > include/linux/cpuset.h | 8 +++---- > kernel/cgroup/cgroup-v1.c | 3 +++ > kernel/cgroup/cgroup.c | 50 +++++++++++++++++++++++++++++++++++---- > kernel/cgroup/cpuset.c | 25 ++++++++++++-------- > 4 files changed, 67 insertions(+), 19 deletions(-) Now queued up, thanks. greg k-h