Received: by 2002:ac0:8c8e:0:0:0:0:0 with SMTP id r14csp733015ima; Wed, 6 Feb 2019 07:30:30 -0800 (PST) X-Google-Smtp-Source: AHgI3IYPtPRZFi0bOFa9Cx5ehc420JKiwfkn9oI6SMHszyVffIZWTJFaizEsaE8LHlSPziiObPnr X-Received: by 2002:a63:ce0e:: with SMTP id y14mr10193204pgf.145.1549467030358; Wed, 06 Feb 2019 07:30:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549467030; cv=none; d=google.com; s=arc-20160816; b=lIFKZgvnS5CY/CTy1E7KzB25DuykUrUoVwuEWxwFKvPjEpJxJyy+RR8+msyHcBPpip uqazc7ovo/BmWlheIS4d6lgzys3CqDtSjY/mm1nVI91ffN5LtUmLLHMB43nVqAib2w+3 fAo5wARaKDvORTJqSu5MdqWnUhpsMknpRSc8kfp30wYNipt2LjNNJlPcYm4troqOgeGp B9syc8I0KmEh9Zcyj76b7vgk8SD51CZYruDySgMKZ2+1tuDdrc3vsI3akBP+I18Qox4R +PXEjFrLZ5Xd7r75PVqmB33WcvRRW6emj0kxZ9CAGNc9PcbVvz1SfJ8xT6yz06dHEZwG nYvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=9IBLfaavppi758OCjdB947t6koYFqHTGyhMEeJMJjcA=; b=I7kI+94Dk3DbO7HPFptE6HUZAKmNgD3UjjuZWqLnorMen1o/sTov1t27TWr+8mazcc RhlbrOy0uQBA3aLVdUNt7pi1T9lU2iwkCoD4nLsH3d9TcOX4RO3+1K14NzQltYcIOaCp 0WZnX4O88OHQjLrzvC84nnDlWIu49Z1quiIL8IKS1oj84m8ntVF3zweWE55jqfTN85I/ rT8yGF7Qh3lfVML7oMdXFY4ikL5fot/0yeWjBsqEruJZXaateIVyictC7dBKHXb5UIXS uQvrwpBqmWBTO83QoYLnbzUjzzKhUHFtWUYTXVZTEEWIn/GkJSrvvFrMwJV7AWKvNpwv xSIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b="WeX1RBp/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j39si6318124plb.272.2019.02.06.07.30.14; Wed, 06 Feb 2019 07:30:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b="WeX1RBp/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731012AbfBFPFe (ORCPT + 99 others); Wed, 6 Feb 2019 10:05:34 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:55112 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730991AbfBFPFc (ORCPT ); Wed, 6 Feb 2019 10:05:32 -0500 Received: by mail-wm1-f67.google.com with SMTP id a62so2821537wmh.4 for ; Wed, 06 Feb 2019 07:05:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9IBLfaavppi758OCjdB947t6koYFqHTGyhMEeJMJjcA=; b=WeX1RBp/CcBQkfXjggkfmEjTC8/LsW/ZK4tTOwMymJy0sFUXTlU5DhRI0QK3AQj7FA dL48Gs73dLPoVlEb5+tPZkqdYCShxowjg4MMz7qz+tGDKZ6VR5GcKMYuSuodqDPXM52B mIKcjGjjxjbyq4BmGlQQogkGUPeOvpiJWf8oW/CGP56Be8GFxhSXuvmCyfY+Ivyuc+Ih RjGvktUGafPHuD/GO2SBHflO3psKkTPDKH1oIOxSP+BTUAorx8US4ShzIo8sEChOuBXF kL51yLqy3ayPh+WOM2mFmxthMmVDr1rBbaZwBe2r2q1pDJYVhBq/wrOlfFUgCuJMuqvf GcBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9IBLfaavppi758OCjdB947t6koYFqHTGyhMEeJMJjcA=; b=Irs8lRmf3sZPngNxmOsFlnssDhnPyc7XRIVhACJ/X+i1Q8Gs2InQAZ1HTjQW774KX7 f85wWnqKrX5xWGe2TwEvRJ4zs1+PHk3kBsdTM9tDMHg0jXZZkA599tirdtZ/KmdDz4pB CZn9yL4GTWkS/v81GXKvL1eI0/NjrRL8YVoh68OqSuQdJhPeoeizZgvYQkfUhY432+mv S1mg3Fi9ek+JXv4A3J9GmRdnXApr3uYVDvkp8edGzRSnIkiOpQicIJgSRJJoQzxgS5Jv e9UV0Ki/69FmdAIhHREPOoTcCUcv2o9YL8rsLtJiDuEvJQFNWzR/GtVilsfoaxhV3oiT nMGQ== X-Gm-Message-State: AHQUAubG14BaByaqUGwbV7tM810CIFNEOsuMSMZ+ZJE40XYsazYHUOIM MAPaM/PWg0LjtK2S8fpZZGTvWA== X-Received: by 2002:a1c:7406:: with SMTP id p6mr3571209wmc.141.1549465529711; Wed, 06 Feb 2019 07:05:29 -0800 (PST) Received: from localhost (p200300C44723CCF50E7AC8E3657171F5.dip0.t-ipconnect.de. [2003:c4:4723:ccf5:e7a:c8e3:6571:71f5]) by smtp.gmail.com with ESMTPSA id v132sm18924789wme.20.2019.02.06.07.05.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Feb 2019 07:05:29 -0800 (PST) From: Johannes Weiner To: Tejun Heo Cc: Andrew Morton , Peter Zijlstra , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH] kernel: workqueue: clarify wq_worker_last_func() caller requirements Date: Wed, 6 Feb 2019 16:05:28 +0100 Message-Id: <20190206150528.31198-1-hannes@cmpxchg.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This function can only be called safely from very specific scheduler contexts. Document those. Suggested-by: Andrew Morton Signed-off-by: Johannes Weiner --- kernel/workqueue.c | 10 ++++++++++ 1 file changed, 10 insertions(+) Andrew suggested including the explanations that came up during the code review in the function doc. As the function has since been merged, sending as follow-up for 5.1. Thanks! diff --git a/kernel/workqueue.c b/kernel/workqueue.c index fc5d23d752a5..23a67b9430da 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -918,6 +918,16 @@ struct task_struct *wq_worker_sleeping(struct task_struct *task) * CONTEXT: * spin_lock_irq(rq->lock) * + * This function is called during schedule() when a kworker is going + * to sleep. It's used by psi to identify aggregation workers during + * dequeuing, to allow periodic aggregation to shut-off when that + * worker is the last task in the system or cgroup to go to sleep. + * + * As this function doesn't involve any workqueue-related locking, it + * only returns stable values when called from inside the scheduler's + * queuing and dequeuing paths, when @task, which must be a kworker, + * is guaranteed to not be processing any works. + * * Return: * The last work function %current executed as a worker, NULL if it * hasn't executed any work yet. -- 2.20.1