Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3995434imu; Mon, 28 Jan 2019 15:01:08 -0800 (PST) X-Google-Smtp-Source: ALg8bN7sE0yTYpDaOCCB/bPgEH296lr8kRitdcYuwM+CxPdkGmSrrVf+qoqKdMMf92xk+TbkNelE X-Received: by 2002:a17:902:4401:: with SMTP id k1mr23790363pld.307.1548716468490; Mon, 28 Jan 2019 15:01:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548716468; cv=none; d=google.com; s=arc-20160816; b=ZSkbI7layYeBHeO8wsCMsMT8xM/jIXqlAV9Wzyx711z5JfaUf7Awc6Gvq3HH2fKBef 0kYJV1Sha8EBkyoZ6EXpVcKpBtbNiaD8nZ4Prcas91KQJhCsZ9/S11EDGBhBQZzYgdwn L0iMJ1VyaZzgEFD4qZ+hASV7ABb6DLZQxhJ3YlSR17KpczL7ZlXdzsigiffTxidjKYVn gVPRs8V9aBNt9RQExw/FJO2c92rOUtT8DFtJA0+072s/O8WMm/WPxJX4FLy2QirRGwzi Ep4SXW1d5cNnJpUGwxYp8mFy4g2qIeQ3KGu7QsqkBnHV6beiBsNza5ElagEvzaODDlLI ec7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=hIJpW7GMeiE3B4vNTAQ6Z5XtbYmf6DLwmTjd/UWH4Co=; b=FkQl2uPcN5kEole6MOfgjatRsDlJ1Tt382BxjmmWtxlszLGosDlFHiRGFRaerxOmce Tj8SmH0rGIVAc1yA2SmaFzmGeu7WRNcpPAxBA5Ae159hb5pVovoUk2Cc7/aIYz3EsdbF MPBhmHtOMeR1j9T1z6wbBzGzAgodOwKLqmePPR8O9gUsCgs8QROqGwfs+PWGy8SK0JF8 0bxJfJ+tiQg5ozTo40G0oFjCCmL6xjfGmLnivWfO0L+sgJoiH53vFM9Rxlt1pCsIsIYH hhm8w3HR+x0rTkfgFkGYbYoXqcHF8O5z5Xk/INyhDLMEzx2LgE0Ys6PV7LIyoO8T4Vqo cl6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=XTIuEQhy; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v9si29096468pfl.45.2019.01.28.15.00.52; Mon, 28 Jan 2019 15:01:08 -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=fail header.i=@gmail.com header.s=20161025 header.b=XTIuEQhy; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726937AbfA1W7S (ORCPT + 99 others); Mon, 28 Jan 2019 17:59:18 -0500 Received: from mail-yw1-f65.google.com ([209.85.161.65]:34717 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726752AbfA1W7R (ORCPT ); Mon, 28 Jan 2019 17:59:17 -0500 Received: by mail-yw1-f65.google.com with SMTP id g75so7480202ywb.1 for ; Mon, 28 Jan 2019 14:59:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=hIJpW7GMeiE3B4vNTAQ6Z5XtbYmf6DLwmTjd/UWH4Co=; b=XTIuEQhyPp+8X6R6TmA5450pqAEouS8UnzVO66rN8NF0wnKp/KW5pDk0RvzQkSkEmx w0lbDx1jMG+qUVex8CiwMXOkOPoI9VFKwDqDTv9UNLB7MM33VCO8HZFTZnPOO9d0ZtSa 4Qtn+33zAXUiZlO+Srqxe4yPb/JEcuMF4Cf2cNlA9XK4bPZaIR8lyoz9l8lVpZPEUqOe L8wqvTKazZKa13wyywqRhhjk0N4FQLRqL1HMzKtgh+gSvTwsIA3xospexgn0+MSQCNIk 9KcEb9eOud2IVukq1qYeEDJUMcCkGldhiUx8ayoE/NBjNm/2zK7vPdigmdQYFcV9dBR4 xlRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=hIJpW7GMeiE3B4vNTAQ6Z5XtbYmf6DLwmTjd/UWH4Co=; b=FVO7+SSYBL2KazZLXYbPKnQb+1RvfN6BRNDdqG4gFsXCZJLJ/a9+eRvfA+aEouXa7n B4V5z6Be8EsTixBKFdQpCJSyH3iu+jTy23noUeTvl44yw6RtxxuUlir/2107NihRaJ2U YGyCQ2EN31B/DEFxNQFgsUpNzNsZkxdRH+VAqzpfMADXN/W4KkMONk1tl/9d4yt8/sca Hde+o2BtlzOzdoI58iwBwPdS+NCmwpUy1Q/Sqm671OLWWOOkSf7Tr1YXXLcdBSiVxxcm hlop6XsSTkC+STdX9Lqu/4b0ANhl+cyssRmKmwG5q4L1Ok2WbX7y4HZ70xCi08Avpel+ 8giQ== X-Gm-Message-State: AJcUukdxm25rUdeypbc3xCYC4zblb74p3/tGcQR0mVmgG/S5oHiWhHtE 3ZGjBBXVnMONgIjluZWjWDc= X-Received: by 2002:a81:3594:: with SMTP id c142mr23621854ywa.234.1548716356317; Mon, 28 Jan 2019 14:59:16 -0800 (PST) Received: from localhost ([2620:10d:c091:200::7:31a1]) by smtp.gmail.com with ESMTPSA id s185sm26391177yws.69.2019.01.28.14.59.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 14:59:15 -0800 (PST) Date: Mon, 28 Jan 2019 14:59:12 -0800 From: Tejun Heo To: Andrew Morton Cc: Johannes Weiner , Peter Zijlstra , Suren Baghdasaryan , Lai Jiangshan , linux-kernel@vger.kernel.org Subject: Re: [PATCH] psi: fix aggregation idle shut-off Message-ID: <20190128225912.GV50184@devbig004.ftw2.facebook.com> References: <20190116193501.1910-1-hannes@cmpxchg.org> <20190128140336.25854cb97c25924f4bfc26c7@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190128140336.25854cb97c25924f4bfc26c7@linux-foundation.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Andrew. On Mon, Jan 28, 2019 at 02:03:36PM -0800, Andrew Morton wrote: > > +#include "../workqueue_internal.h" > > "Only to be included by workqueue and core kernel subsystems" > > I'm not sure that psi qualifies. Perhaps wq_worker_last_func() should > be declared in include/linux/workqueue.h. > > And perhaps implemented there as well. It's similar to > current_wq_worker(), which is inlined and wq_worker_last_func() is > small enough to justify inlining. workqueue_internal.h is used mostly to expose some of the internal details and hooks to scheduler code for concurrency management. Most of PSI is tracking state transitions on scheduling events (psi.c is under kernel/sched/ for this reason), so it's mostly in line with how the file was being used. I think keeping it in workqueue_internal.h is better. Please see below. > > +work_func_t wq_worker_last_func(struct task_struct *task) > > +{ > > + struct worker *worker = kthread_data(task); > > + > > + return worker->last_func; > > +} > > The semantics are troublesome. What guarantees that worker->last_func > won't change under the caller's feet? The caller should hold some lock > (presumably worker->pool->lock) in order to stabilize the > wq_worker_last_func() return value? > > Also, the comment isn't really true - this is called from PSI, which is > hardly "the scheduler"? Hmm... This is the same way wq_worker_waking_up() and wq_worker_sleeping() are synchronized. The task being queried is being scheduled in or out, so it can't change underneath and is in line with other stuff in kernel_internal.h. Thanks. -- tejun