Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4894202rwb; Tue, 6 Sep 2022 14:43:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR7G6GEACmD9H03WShJchI+9iOhb/11t6lz2rDI3TrCuX/trHhqIDHTi1/sxUumV+75Z37q0 X-Received: by 2002:a05:6402:148e:b0:44e:aa8c:abc5 with SMTP id e14-20020a056402148e00b0044eaa8cabc5mr495414edv.145.1662500593241; Tue, 06 Sep 2022 14:43:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662500593; cv=none; d=google.com; s=arc-20160816; b=Y0qO1y4t1Cp2iRn09a5pLggR/Vpm+mywMf+2YrUnI+dGBchGgNjapN6UyKNhklSTTp KDyWBP/qk9P4VTpVUEFAMzghFhHaZf4l08mYWzvY9S44IDt+Cm1l4tH/KD4EJ2FG//b2 Op6ourpV8k176Cd9XrxZauIWLZtMbtHVzH/BoXhqJfeVAVY4Bgu0iW3KC58NxdnEc38N y5VNB7RxSvNcdGWk+558HXKnY78cOoyhPEQEXItJV2UQDig+h6kdYs9u72MCEoouG4j6 OuAUcY0bwO5ubqcdl9DbEW24ChLwUFuY7r6xFL62g8e6mia3dKwNT0loXW+wQRgHN9oo 7D+Q== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=GzCE/imuOcJ+g/sNBTROhEBFbz+670zTIBkR3Ox5lik=; b=fFrCyXGXVfgLWtB12Ho0tcS0iVMbetOpgw9VOaKFcN4IENcqQ/RPWWXScHALq5DRls kGfQYztqriP6g51l/hFxs4Mv/rZAdZfxwN/8OqYuhvZlmolwRYECySDmAgdWGRrG2ysw HxS8m9qMIu6szLlJdZ5eh7cwmBpHexyP1b822V2sAV2n6z9OF55smY2tRnVO0n7ffp62 LCF9y07v0V6DHhoezzfyykMFsOIxlvG29+434FJ2xwdUvXlW2+oyBRCWk4OEk/o6yQS6 A9ZtxF0ZH/+WnBgCCdeKznIPiDatcwMpbN6+9InHP+3h22oP7KHEBFEDBOLd3Ac1Fcnn I1hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=Wq8JJC2I; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hq30-20020a1709073f1e00b00730a1f063fasi2052585ejc.132.2022.09.06.14.42.47; Tue, 06 Sep 2022 14:43:13 -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=@infradead.org header.s=desiato.20200630 header.b=Wq8JJC2I; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231331AbiIFUvI (ORCPT + 99 others); Tue, 6 Sep 2022 16:51:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbiIFUvG (ORCPT ); Tue, 6 Sep 2022 16:51:06 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC17779A5A; Tue, 6 Sep 2022 13:51:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=GzCE/imuOcJ+g/sNBTROhEBFbz+670zTIBkR3Ox5lik=; b=Wq8JJC2I8k9ghAF1rh90IxH1g1 6B5eeRWNA2ClA+/QuqBjIVPG+vOa3naUYz8tkXZegSrBEdZEUeeyQPxJ0M4MXqQrI5I68PDnyDsIb QUgqk3THblmxaJlRawNJTfv6AOvl5GQkHL++vjZRa4qhEObP5x3vbkUhKXKqmK2zhil4k31p4BUsu 1w86Xyg88pCB74zI6M76HtjoaEcEEo5ZB6xGGgIozCgqSwYMb5IuzzkpupWExTX+bjHBZJlz3wYfp hvEBL908KQXs42Ckacb877wbojdN45KH60/PEhO7xReXrO6e8NWPxkfmSW/OXKYC3P2CnbKHaRWyi a9Ozu7dQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVfWf-00AGIo-Vn; Tue, 06 Sep 2022 20:50:30 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 1F3AD3006A4; Tue, 6 Sep 2022 22:50:28 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id CEECF203C095B; Tue, 6 Sep 2022 22:50:28 +0200 (CEST) Date: Tue, 6 Sep 2022 22:50:28 +0200 From: Peter Zijlstra To: Waiman Long Cc: Tejun Heo , Jing-Ting Wu , Mukesh Ojha , Valentin Schneider , wsd_upstream@mediatek.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Jonathan.JMChen@mediatek.com, "chris.redpath@arm.com" , Dietmar Eggemann , Vincent Donnefort , Ingo Molnar , Juri Lelli , Vincent Guittot , Steven Rostedt , Ben Segall , Mel Gorman , Christian Brauner , cgroups@vger.kernel.org, lixiong.liu@mediatek.com, wenju.xu@mediatek.com Subject: Re: BUG: HANG_DETECT waiting for migration_cpu_stop() complete Message-ID: References: <88b2910181bda955ac46011b695c53f7da39ac47.camel@mediatek.com> <203d4614c1b2a498a240ace287156e9f401d5395.camel@mediatek.com> <02b8e7b3-941d-8bb9-cd0e-992738893ba3@redhat.com> <36a73401-7011-834a-7949-c65a2f66246c@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <36a73401-7011-834a-7949-c65a2f66246c@redhat.com> 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_NONE,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 On Tue, Sep 06, 2022 at 04:40:03PM -0400, Waiman Long wrote: I've not followed the earlier stuff due to being unreadable; just reacting to this.. > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index 838623b68031..5d9ea1553ec0 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -2794,9 +2794,9 @@ static int __set_cpus_allowed_ptr_locked(struct > task_struct *p, > ??????????????? if (cpumask_equal(&p->cpus_mask, new_mask)) > ??????????????????????? goto out; > > -?????????????? if (WARN_ON_ONCE(p == current && > -??????????????????????????????? is_migration_disabled(p) && > -??????????????????????????????? !cpumask_test_cpu(task_cpu(p), new_mask))) > { > +?????????????? if (is_migration_disabled(p) && > +?????????????????? !cpumask_test_cpu(task_cpu(p), new_mask)) { > +?????????????????????? WARN_ON_ONCE(p == current); > ??????????????????????? ret = -EBUSY; > ??????????????????????? goto out; > ??????????????? } > @@ -2818,7 +2818,11 @@ static int __set_cpus_allowed_ptr_locked(struct > task_struct *p, > ??????? if (flags & SCA_USER) > ??????????????? user_mask = clear_user_cpus_ptr(p); > > -?????? ret = affine_move_task(rq, p, rf, dest_cpu, flags); > +?????? if (!is_migration_disabled(p) || (flags & SCA_MIGRATE_ENABLE)) { > +?????????????? ret = affine_move_task(rq, p, rf, dest_cpu, flags); > +?????? } else { > +?????????????? task_rq_unlock(rq, p, rf); > +?????? } This cannot be right. There might be previous set_cpus_allowed_ptr() callers that are blocked and waiting for the task to land on a valid CPU.