Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp21115pxb; Wed, 24 Feb 2021 16:59:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwFP3xC+8u/55Bo5ZTJeS1x2vocOdP8v7/CIVhmiBqZxxg3dS/9mRnhoLE602mrIRWETuT0 X-Received: by 2002:aa7:ca57:: with SMTP id j23mr481666edt.293.1614214788581; Wed, 24 Feb 2021 16:59:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614214788; cv=none; d=google.com; s=arc-20160816; b=AEqUA1/iPbeGXbNxuYGBAbzXVylE74fbajjnqBsM8mM5gJZ3YtXa9gs757MJTldxdQ hirE9XwfskvkL8lpt6qggoSljsA5/RPyl1THe/iS9VBW5LdiBW9Q+LcPKSj+H78LCOHZ 8+tJnH6tObp7ocGEzQyv5TpI/tHUCxqhxZTE7GkbRizZ1xoo1+0AQdAiFJxlPZ1DPLSG ltfCkiu4G4Qus2OTHUKdN61C5KMHDkQywVTeYywmBXed+yJclDJOr8ZuZYoEHcYwhdRP vSYJpqT8d77SQE12rzx9yQsQ3Y8bDjPvjmSXQfrtxyOlpX24LxXHY+1PkkXnU4uSLMOb xlHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from; bh=64an6DvSmwZ4QS+VNTgoF6kSUlWH0JRHxeORrxJAe/k=; b=xsD1p/8ok+hLjUINcvM7j0frvjeuJO5gE/hDfIFBRkjiOP3f3uTU4g1KT8L0hD25bW onVdyCCJDl48m5Xe7NOWENaGYCRdLPPbVZGt5gqX1rNdDVNsaSsF3pv/svtfYO+rFCvp gm0Pe/ABKN1UnPNYUctMNPkfDplHSRpVWpJDcGectkluA0rQLXuxgiRlZsjqwaHFTL3s uDWkAocEOWVXao5+W/L4szd+o7YNebIdOmOg8SRPWa8aWww1fQxqY3gqLGiMS/EDZC2m WaDYIIJxTlx7o4UGrd/wFA0h+xOtN3AuJjo/tv5USdRj22fWBMclKl3VG1epHUV1aMMN xDQQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cf25si2470959ejb.636.2021.02.24.16.59.22; Wed, 24 Feb 2021 16:59:48 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236165AbhBXPrp (ORCPT + 99 others); Wed, 24 Feb 2021 10:47:45 -0500 Received: from foss.arm.com ([217.140.110.172]:36876 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231942AbhBXPfl (ORCPT ); Wed, 24 Feb 2021 10:35:41 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 47BDE31B; Wed, 24 Feb 2021 07:34:43 -0800 (PST) Received: from e113632-lin (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 102123F70D; Wed, 24 Feb 2021 07:34:41 -0800 (PST) From: Valentin Schneider To: Peter Zijlstra , Ingo Molnar , Thomas Gleixner Cc: Vincent Guittot , Mel Gorman , Dietmar Eggemann , linux-kernel@vger.kernel.org, peterz@infradead.org, Andi Kleen Subject: Re: [PATCH 2/6] sched: Simplify migration_cpu_stop() In-Reply-To: <20210224131355.430014682@infradead.org> References: <20210224122439.176543586@infradead.org> <20210224131355.430014682@infradead.org> User-Agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/26.3 (x86_64-pc-linux-gnu) Date: Wed, 24 Feb 2021 15:34:36 +0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24/02/21 13:24, Peter Zijlstra wrote: > @@ -1950,31 +1931,20 @@ static int migration_cpu_stop(void *data > goto out; > > if (pending) { > - p->migration_pending = NULL; > + if (p->migration_pending == pending) > + p->migration_pending = NULL; > complete = true; > } > > - /* migrate_enable() -- we must not race against SCA */ > - if (dest_cpu < 0) { > - /* > - * When this was migrate_enable() but we no longer > - * have a @pending, a concurrent SCA 'fixed' things > - * and we should be valid again. Nothing to do. > - */ > - if (!pending) { > - WARN_ON_ONCE(!cpumask_test_cpu(task_cpu(p), &p->cpus_mask)); > - goto out; > - } > - This is fixed by 5+6, but at this patch I think you can have double completions - I thought this was an issue, but briefly looking at completion stuff it might not. In any case, consider: task_cpu(p) == Y SCA(p, X); SCA(p, Y); SCA(p, Y) will uninstall SCA(p, X)'s pending and complete. migration/Y kicked by SCA(p, X) will grab arg->pending, which is still SCA(p, X)'s pending and also complete. > + if (dest_cpu < 0) > dest_cpu = cpumask_any_distribute(&p->cpus_mask); > - } > > if (task_on_rq_queued(p)) > rq = __migrate_task(rq, &rf, p, dest_cpu); > else > p->wake_cpu = dest_cpu; > > - } else if (dest_cpu < 0 || pending) { > + } else if (pending) { > /* > * This happens when we get migrated between migrate_enable()'s > * preempt_enable() and scheduling the stopper task. At that