Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp4112352pxb; Tue, 17 Nov 2020 11:34:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJyEmOOWQHa2Bd7g+407EFIA7Hy2JsBAiMsDza7cea/7+v7DomUbUfAOrzcJt7UrJrGeR0aQ X-Received: by 2002:a50:8245:: with SMTP id 63mr22640800edf.133.1605641690188; Tue, 17 Nov 2020 11:34:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605641690; cv=none; d=google.com; s=arc-20160816; b=EjI0QKHq9Jqn25kiTdWC1+FrFraoozSo5d8Gqrtb4J0Ys8N6FEw+zK3ejxrgz2Td6W BksRj4JjYe7bnDf+Q6DDaz34/y7YEV0ZnmZp0/4KSJ9lbONi72MtWhzkJkcgBNygNnjC vZBZ2PUsNh9bC55K0kI4cQ/yET/zKW4EcKxZRU9K3eTEaSrowSXfb1e1EBSqDX2/8+ad O8XyxfG0BnLOUCXszksKliaSB+vdkwJcIqtevznYnGZf8zcEyOUUxEia3P+ianhviuZx pydo1AEg0J7212ngQ2YBJpZxjNbPIeiEOqiiIB8DjB2oJJ7Z+iUavVLCUVSQrOQmaiXN yfQw== 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:in-reply-to:subject :cc:to:from:user-agent:references; bh=8IlL+mLNtgePRrS2npAQOfsjvqzEiQ+Owuq2gjs08eg=; b=BeXnn2mX5Nun5hWbcybWOiatEpNs4X91LK1qz36gt1rRzF6oGu7m4DnSULoyEaVoFh rEwTLC5ue3nlMTBDqCOzh/Lde4GxpcuTTcps+g0wPyOXwQEC/3NW7nUp4YjgBFWVhpFi yLfbIoDA0f+7vbYFqEemWtC/vBI9O2BJ6gIvxXn8a86Cz6JNG2MsucLMxJBLanvHwZxP qcsBlejmH9gTKu+hGA8N0X/LlSqKX1Ig/bZytF/4JtRg0aHrB9fXk2qoR97S0RBwY0jJ Bxd0ysxOYPA+bKWIGv4w4VAkMWIWU+J+t5xI1wkDl1DtBySJeQX1mRJeUOkhQtAv0wgf CDYw== 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 a4si5498258eda.235.2020.11.17.11.34.27; Tue, 17 Nov 2020 11:34:50 -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 S1729130AbgKQTcV (ORCPT + 99 others); Tue, 17 Nov 2020 14:32:21 -0500 Received: from foss.arm.com ([217.140.110.172]:35518 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726035AbgKQTcU (ORCPT ); Tue, 17 Nov 2020 14:32:20 -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 1F899101E; Tue, 17 Nov 2020 11:32:20 -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 348B93F718; Tue, 17 Nov 2020 11:32:19 -0800 (PST) References: <20201116131102.GA29992@willie-the-truck> <20201116133721.GQ3371@techsingularity.net> <20201116142005.GE3121392@hirez.programming.kicks-ass.net> <20201116193149.GW3371@techsingularity.net> <20201117083016.GK3121392@hirez.programming.kicks-ass.net> <20201117091545.GA31837@willie-the-truck> <20201117092936.GA3121406@hirez.programming.kicks-ass.net> <20201117094621.GE3121429@hirez.programming.kicks-ass.net> <20201117161318.GP3121392@hirez.programming.kicks-ass.net> User-agent: mu4e 0.9.17; emacs 26.3 From: Valentin Schneider To: Peter Zijlstra Cc: Will Deacon , Mel Gorman , Davidlohr Bueso , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] sched: Fix data-race in wakeup In-reply-to: <20201117161318.GP3121392@hirez.programming.kicks-ass.net> Date: Tue, 17 Nov 2020 19:32:16 +0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17/11/20 16:13, Peter Zijlstra wrote: > On Tue, Nov 17, 2020 at 03:37:24PM +0000, Valentin Schneider wrote: > >> >> + /* >> >> + * This field must not be in the scheduler word above due to wakelist >> >> + * queueing no longer being serialized by p->on_cpu. However: >> >> + * >> >> + * p->XXX = X; ttwu() >> >> + * schedule() if (p->on_rq && ..) // false >> >> + * smp_mb__after_spinlock(); if (smp_load_acquire(&p->on_cpu) && //true >> >> + * deactivate_task() ttwu_queue_wakelist()) >> >> + * p->on_rq = 0; p->sched_remote_wakeup = Y; >> >> + * >> >> + * guarantees all stores of 'current' are visible before >> >> + * ->sched_remote_wakeup gets used, so it can be in this word. >> >> + */ >> > >> > Isn't the control dep between that ttwu() p->on_rq read and >> > p->sched_remote_wakeup write "sufficient"? >> >> smp_acquire__after_ctrl_dep() that is, since we need >> ->on_rq load => 'current' bits load + store > > I don't think we need that extra barrier; after all, there will be a > complete schedule() between waking the task and it actually becoming > current. Apologies for the messy train of thought; what I was trying to say is that we have already the following, which AIUI is sufficient: * p->XXX = X; ttwu() * schedule() if (p->on_rq && ..) // false * smp_mb__after_spinlock(); smp_acquire__after_ctrl_dep(); * deactivate_task() ttwu_queue_wakelist() * p->on_rq = 0; p->sched_remote_wakeup = Y;