Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp613360pxb; Thu, 12 Nov 2020 11:43:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBUqs4UgKfK8r0g8jJZ9ln7f3pO89ii5Y0j8h/E/hvxC2dzB0hHZsKEMEgifGNGV1ZLbkX X-Received: by 2002:a17:906:604e:: with SMTP id p14mr909596ejj.515.1605210212014; Thu, 12 Nov 2020 11:43:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605210212; cv=none; d=google.com; s=arc-20160816; b=xpeYFLAZkh5Z+okwbGav5r9KrApDQx3oscZv6rDiY/fIfaKZPOwRibZb9cfNGRZtnr SWTfU79K/Dih2R6YoSdeTyxGZBZ1R0kBj3VMtbHQCqyiwyVcTHwPEmt6oW5TfnAf5c1f 6vtSLOE4OFvnqo6t7BvCxwzYYu+5znDSrxX54K+uGmYuyUFucpyV8WwoByCfT/yjnPgu E8a6Ye6NyhZxgah6lyxtR/hnqW7LudqJNQ4OdBSJdmLxSQkObWz/X+sBw6yQXfmqK/Fr TGsewUSNK5xoSSeaMcWdB5jpw76RPyA1uchk7f8E4F8xUZmQtRcnZjcEFKbE1kHRFDJ6 rkmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature; bh=B23U3gg95JNs9PQEfTQosUDSG0cp4zCcIfz1B+t7gA8=; b=Il5MRUjGBvzjgGWUrwjMpPFoc6iwOtZZftbKjkY7Kfl7l73gzEaBUWr53cucUId3nc JDXIyTFpLED3WzBATituSpdolL/g3K2UBXKGE0VPVHmxm8ANjpjmNwt09tZ6Dlu62u3c xdHAfsO/57p+fPoR7o3lDF+uyJlt2tLUO83zFd0kHijzRkc4rL2Jw5H0c3+wnPNpP8Pp Ddgiar4eYOOCz3SN8jhWcZjy8LCAa1PHyUU5Yk8cLq0J4qaibPlzKsQvxdhKGCZYfcNB /On5WLKim/OoqF4Tv+Kp8dhOhwYcItnR5jwuKxmrn03O9Xyu09EcKs0Whf9Fnr9xaxXr OrGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ffnPr5rR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c5si4616290edw.91.2020.11.12.11.43.08; Thu, 12 Nov 2020 11:43:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ffnPr5rR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726776AbgKLTlv (ORCPT + 99 others); Thu, 12 Nov 2020 14:41:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53711 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726310AbgKLTlu (ORCPT ); Thu, 12 Nov 2020 14:41:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605210110; 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=B23U3gg95JNs9PQEfTQosUDSG0cp4zCcIfz1B+t7gA8=; b=ffnPr5rR8bGRpIjBZPoSLXOpDYtU2xDi0Aq0jjnveDVwzpxg91s/352wgfeDYFGvZ4BasT ge7KSLcB1MZjrgRT2//vvgdplprgxIQvQBh5KPEeK8EtMQccylRrYvYf3MhP8fe0+q5453 GK5YLxw87+0HiZxxuojjhnW+H1NF+xQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-15-FeSgfCcVP_mA90IFEUIXbQ-1; Thu, 12 Nov 2020 14:41:46 -0500 X-MC-Unique: FeSgfCcVP_mA90IFEUIXbQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F0244803625; Thu, 12 Nov 2020 19:41:43 +0000 (UTC) Received: from ovpn-66-145.rdu2.redhat.com (ovpn-66-145.rdu2.redhat.com [10.10.66.145]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C0905B4B2; Thu, 12 Nov 2020 19:41:35 +0000 (UTC) Message-ID: Subject: Re: [PATCH v4 10/19] sched: Fix migrate_disable() vs set_cpus_allowed_ptr() From: Qian Cai To: Valentin Schneider Cc: Peter Zijlstra , tglx@linutronix.de, mingo@kernel.org, linux-kernel@vger.kernel.org, bigeasy@linutronix.de, qais.yousef@arm.com, swood@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vincent.donnefort@arm.com, tj@kernel.org, ouwen210@hotmail.com Date: Thu, 12 Nov 2020 14:41:34 -0500 In-Reply-To: References: <20201023101158.088940906@infradead.org> <20201023102346.921768277@infradead.org> <8b62fd1ad1b18def27f18e2ee2df3ff5b36d0762.camel@redhat.com> <13786aa5a5fc958708ef1182c885d1a574449d99.camel@redhat.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2020-11-12 at 19:31 +0000, Valentin Schneider wrote: > One thing I don't get: that trace shows refcount_dec_and_test() > (kernel/sched/core.c:2263) happening before the wait_for_completion(). It's > not the case in the below trace. Yes, that is normal. Sometimes, the decoding is a bit off not sure because of some debugging options like KASAN obscures it. > a) Do you also get this on CONFIG_PREEMPT=y? I don't know. None of the systems here has that, but I could probably try. > b) Could you try the below? Let me run it and report. > > --- > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index 02076e6d3792..fad0a8e62aca 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -1923,7 +1923,7 @@ static int migration_cpu_stop(void *data) > else > p->wake_cpu = dest_cpu; > > - } else if (dest_cpu < 0) { > + } else if (dest_cpu < 0 || pending) { > /* > * This happens when we get migrated between migrate_enable()'s > * preempt_enable() and scheduling the stopper task. At that > @@ -1933,6 +1933,17 @@ static int migration_cpu_stop(void *data) > * more likely. > */ > > + /* > + * The task moved before the stopper got to run. We're holding > + * ->pi_lock, so the allowed mask is stable - if it got > + * somewhere allowed, we're done. > + */ > + if (pending && cpumask_test_cpu(task_cpu(p), p->cpus_ptr)) { > + p->migration_pending = NULL; > + complete = true; > + goto out; > + } > + > /* > * When this was migrate_enable() but we no longer have an > * @pending, a concurrent SCA 'fixed' things and we should be >