From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB9C5C38145 for ; Tue, 6 Sep 2022 21:02:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230075AbiIFVCg (ORCPT ); Tue, 6 Sep 2022 17:02:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229673AbiIFVC1 (ORCPT ); Tue, 6 Sep 2022 17:02:27 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A57159E0FF for ; Tue, 6 Sep 2022 14:02:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662498145; 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=wOjFY7tNKFL7dFNVA6yx/TeGWvfp5wOKn+I8yQQqSS4=; b=Ju1onuYKug+swmkdBSR2v9LEcsyecazwiRANYZ+KIu+KoHu6PWTbDpqtyuxhN05GZ9v+8L 13I/ulcBuKPc5Lk+yG/+l8MbFAbHj6oopJ3q/DZ4KhH3wjohejS6VB/V48CeyOpVsCLI9I 8gBMWMaF0AY/0KNEyOGFqYstH12kp1M= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-375-WupwlPYUPr2I2vTup4ohvA-1; Tue, 06 Sep 2022 17:02:22 -0400 X-MC-Unique: WupwlPYUPr2I2vTup4ohvA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 792CC1C05EAC; Tue, 6 Sep 2022 21:02:21 +0000 (UTC) Received: from [10.18.17.215] (dhcp-17-215.bos.redhat.com [10.18.17.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id C17CEC15BC3; Tue, 6 Sep 2022 21:02:20 +0000 (UTC) Message-ID: <879886ba-7d77-11fc-5357-b21e141637ef@redhat.com> Date: Tue, 6 Sep 2022 17:02:20 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: BUG: HANG_DETECT waiting for migration_cpu_stop() complete Content-Language: en-US To: Peter Zijlstra 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 References: <88b2910181bda955ac46011b695c53f7da39ac47.camel@mediatek.com> <203d4614c1b2a498a240ace287156e9f401d5395.camel@mediatek.com> <02b8e7b3-941d-8bb9-cd0e-992738893ba3@redhat.com> <36a73401-7011-834a-7949-c65a2f66246c@redhat.com> From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/6/22 16:50, Peter Zijlstra wrote: > 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. You are probably right. I haven't fully understand all the migration disable code yet. However, if migration is disabled, there are some corner cases we need to handle properly. Cheers, Longman From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5F9D5C38145 for ; Tue, 6 Sep 2022 21:03:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LorOjDDT/fplW4o9M9yVzukdw/nyL/b0oCE/3FvC37Y=; b=gTftFW+l7ojGDF g6LCdek5a3woaWPXkCSYyzm7OZFC4CWgqXiy2X4RGiKdqMhCK6eIVtcKuBYeGg+ZFgJVGsuQ9/H9z KfmdfrCMRFoaEQJu0wMo0FWYulapLwcZ53bZeP9tFts1iMiErv0TeXfuCBgLP7CcwnZzDCH7ttKP8 LaY9YyWgmtx2AtWRY0C9LeZHDG2d+j28DzKa02RnmCBFL4M2f0nsCGqfz4+bUgt7CdAWTVrD9gHj1 3U47nUsmViyoYThNA4DQHmv1PJMSxHBYXco5L7ykM9qazwkjUFu1g/LBQWGtTkJR5GPFSrPfQtbek g+hcneoEVnLCghGAVqmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVfiJ-00HLQ9-BT; Tue, 06 Sep 2022 21:02:31 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVfiF-00HLOW-Er for linux-arm-kernel@lists.infradead.org; Tue, 06 Sep 2022 21:02:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662498146; 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=wOjFY7tNKFL7dFNVA6yx/TeGWvfp5wOKn+I8yQQqSS4=; b=YWScDXtv66RV73VtSW7wVdjB601jnvwqbR9Ffc62mMGTdSefJrEwaUf/Qh7BXTT7axdKLL qbtqXG2YsSSLm2e7Qg/cJD+5futSZJBrLVMn8bpN3Nbje+G0IRURFPsxmF1fJ7Jz7eFTDW ndvTuBxfKHwYytfPcz6pzsBeGj8H8D4= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-375-WupwlPYUPr2I2vTup4ohvA-1; Tue, 06 Sep 2022 17:02:22 -0400 X-MC-Unique: WupwlPYUPr2I2vTup4ohvA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 792CC1C05EAC; Tue, 6 Sep 2022 21:02:21 +0000 (UTC) Received: from [10.18.17.215] (dhcp-17-215.bos.redhat.com [10.18.17.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id C17CEC15BC3; Tue, 6 Sep 2022 21:02:20 +0000 (UTC) Message-ID: <879886ba-7d77-11fc-5357-b21e141637ef@redhat.com> Date: Tue, 6 Sep 2022 17:02:20 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: BUG: HANG_DETECT waiting for migration_cpu_stop() complete Content-Language: en-US To: Peter Zijlstra 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 References: <88b2910181bda955ac46011b695c53f7da39ac47.camel@mediatek.com> <203d4614c1b2a498a240ace287156e9f401d5395.camel@mediatek.com> <02b8e7b3-941d-8bb9-cd0e-992738893ba3@redhat.com> <36a73401-7011-834a-7949-c65a2f66246c@redhat.com> From: Waiman Long In-Reply-To: X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220906_140227_579978_F432EB64 X-CRM114-Status: GOOD ( 19.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: base64 Content-Type: text/plain; charset="utf-8"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Ck9uIDkvNi8yMiAxNjo1MCwgUGV0ZXIgWmlqbHN0cmEgd3JvdGU6Cj4gT24gVHVlLCBTZXAgMDYs IDIwMjIgYXQgMDQ6NDA6MDNQTSAtMDQwMCwgV2FpbWFuIExvbmcgd3JvdGU6Cj4KPiBJJ3ZlIG5v dCBmb2xsb3dlZCB0aGUgZWFybGllciBzdHVmZiBkdWUgdG8gYmVpbmcgdW5yZWFkYWJsZTsganVz dAo+IHJlYWN0aW5nIHRvIHRoaXMuLgo+Cj4+IGRpZmYgLS1naXQgYS9rZXJuZWwvc2NoZWQvY29y ZS5jIGIva2VybmVsL3NjaGVkL2NvcmUuYwo+PiBpbmRleCA4Mzg2MjNiNjgwMzEuLjVkOWVhMTU1 M2VjMCAxMDA2NDQK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c19hbGxvd2VkX3B0cigpCj4gY2Fs bGVycyB0aGF0IGFyZSBibG9ja2VkIGFuZCB3YWl0aW5nIGZvciB0aGUgdGFzayB0byBsYW5kIG9u IGEgdmFsaWQKPiBDUFUuCgpZb3UgYXJlIHByb2JhYmx5IHJpZ2h0LiBJIGhhdmVuJ3QgZnVsbHkg dW5kZXJzdGFuZCBhbGwgdGhlIG1pZ3JhdGlvbiAKZGlzYWJsZSBjb2RlIHlldC4gSG93ZXZlciwg aWYgbWlncmF0aW9uIGlzIGRpc2FibGVkLCB0aGVyZSBhcmUgc29tZSAKY29ybmVyIGNhc2VzIHdl IG5lZWQgdG8gaGFuZGxlIHByb3Blcmx5LgoKQ2hlZXJzLApMb25nbWFuCgoKX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KbGludXgtYXJtLWtlcm5lbCBtYWls aW5nIGxpc3QKbGludXgtYXJtLWtlcm5lbEBsaXN0cy5pbmZyYWRlYWQub3JnCmh0dHA6Ly9saXN0 cy5pbmZyYWRlYWQub3JnL21haWxtYW4vbGlzdGluZm8vbGludXgtYXJtLWtlcm5lbAo= From mboxrd@z Thu Jan 1 00:00:00 1970 From: Waiman Long Subject: Re: BUG: HANG_DETECT waiting for migration_cpu_stop() complete Date: Tue, 6 Sep 2022 17:02:20 -0400 Message-ID: <879886ba-7d77-11fc-5357-b21e141637ef@redhat.com> 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-Transfer-Encoding: 8bit Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662498145; 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=wOjFY7tNKFL7dFNVA6yx/TeGWvfp5wOKn+I8yQQqSS4=; b=Ju1onuYKug+swmkdBSR2v9LEcsyecazwiRANYZ+KIu+KoHu6PWTbDpqtyuxhN05GZ9v+8L 13I/ulcBuKPc5Lk+yG/+l8MbFAbHj6oopJ3q/DZ4KhH3wjohejS6VB/V48CeyOpVsCLI9I 8gBMWMaF0AY/0KNEyOGFqYstH12kp1M= Content-Language: en-US In-Reply-To: List-ID: Content-Type: text/plain; charset="utf-8"; format="flowed" To: Peter Zijlstra Cc: Tejun Heo , Jing-Ting Wu , Mukesh Ojha , Valentin Schneider , wsd_upstream-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, Jonathan.JMChen-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org, "chris.redpath-5wv7dgnIgG8@public.gmane.org" , Dietmar Eggemann , Vincent Donnefort , Ingo Molnar , Juri Lelli , Vincent Guittot , Steven Rostedt , Ben Segall , Mel Gorman , Christian Brauner , cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, lixiong.liu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org, wenju.xu On 9/6/22 16:50, Peter Zijlstra wrote: > 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. You are probably right. I haven't fully understand all the migration disable code yet. However, if migration is disabled, there are some corner cases we need to handle properly. Cheers, Longman