Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3400769pxb; Mon, 4 Oct 2021 01:16:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygGSIKrEC0sFBd2LeKxOK6+03lS24oKvCdUmV0pYROVX9JKFJ9UC5iBCMWuVKI+MZFTkUw X-Received: by 2002:a63:e14f:: with SMTP id h15mr9751792pgk.49.1633335404867; Mon, 04 Oct 2021 01:16:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633335404; cv=none; d=google.com; s=arc-20160816; b=q/6Em0gbDVKRW8+eC93cNkZwfWypgW3rIwlZLoFjmOtl6Up9Hr9nnSQ1iv/h3Fhk71 anS+kKWRhQeTYB7vctO6UsEG2H4V54RYYERt3iW7Vpp6eNXXpuiWx7ZSxv/ULTFcmOaz KbUR8Y82mbpUlQRmd3nbM3FnXaugmbZzpGNM7EB56d9biF7FH8dwdpfzr82mVa8l1k05 Xzs5RTMU0FCO5w7mYc4tD7drPoP+BRkBCCF7v1WenggqoHf4b9yieR6U/vfTUVYMqILP N/nRBbv4oO+y5tNAJ4sa11Jj5ZagmwAsEfqi2IAQCAyJfeFkd2mC1cciXENeXLrs9L1W 7Wxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject; bh=4CEf0hfMQSKF6N/bJNybVTmcOtLw66lxNGcOAcBdesM=; b=TITGxi+qUdZU1tJ1f3iFP4T3XkkThBLlOYIQ/P9Ytndp7XKdWduUsHsf3QHbqgnRp7 5WAfJitvvgLBLEv+xZBqaUt08gaIp58ZO+2H5rkIc69rUBDX8AsrQa2p4Ipi1wUk+YjD tZIRbFlpY3hCQljDme9LloRMfqsq99vd0eAEgTttdTYOQaaCbIbvP9WcgaqVGN+Tns2o nkFuhhjgsxYjg2rDVv/pbPK/831MIEumaLAD1G2UkxDAwO3DUgLrypVb4Hb8vgWuSH2k wjeb78+77VSXzkOvuy0vy7xqGl/+6/WrchKV5LmRkksh1paEsdv33/Nd4cJb2FprL0QZ VVtw== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t21si35605pfl.246.2021.10.04.01.16.31; Mon, 04 Oct 2021 01:16:44 -0700 (PDT) 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231247AbhJDIPY (ORCPT + 99 others); Mon, 4 Oct 2021 04:15:24 -0400 Received: from mga17.intel.com ([192.55.52.151]:34847 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230185AbhJDIPX (ORCPT ); Mon, 4 Oct 2021 04:15:23 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10126"; a="206140460" X-IronPort-AV: E=Sophos;i="5.85,345,1624345200"; d="scan'208";a="206140460" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Oct 2021 01:12:46 -0700 X-IronPort-AV: E=Sophos;i="5.85,345,1624345200"; d="scan'208";a="482815518" Received: from shearne-mobl.ger.corp.intel.com (HELO [10.213.208.122]) ([10.213.208.122]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Oct 2021 01:12:41 -0700 Subject: Re: [RFC 1/6] sched: Add nice value change notifier To: Peter Zijlstra Cc: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Tvrtko Ursulin , Ingo Molnar , Juri Lelli , Vincent Guittot References: <20210930171552.501553-1-tvrtko.ursulin@linux.intel.com> <20210930171552.501553-2-tvrtko.ursulin@linux.intel.com> <20210930183316.GC4323@worktop.programming.kicks-ass.net> <4aca656d-678f-4d61-38a4-d2e7a8fd89ab@linux.intel.com> <5c71ec04-9148-0587-c495-11dbd8f77d67@linux.intel.com> From: Tvrtko Ursulin Organization: Intel Corporation UK Plc Message-ID: <01a968c9-c427-f4c7-44d5-2f47f939f9eb@linux.intel.com> Date: Mon, 4 Oct 2021 09:12:37 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/10/2021 16:48, Peter Zijlstra wrote: > On Fri, Oct 01, 2021 at 11:32:16AM +0100, Tvrtko Ursulin wrote: >> >> On 01/10/2021 10:04, Tvrtko Ursulin wrote: >>> >>> Hi Peter, >>> >>> On 30/09/2021 19:33, Peter Zijlstra wrote: >>>> On Thu, Sep 30, 2021 at 06:15:47PM +0100, Tvrtko Ursulin wrote: >>>>>   void set_user_nice(struct task_struct *p, long nice) >>>>>   { >>>>>       bool queued, running; >>>>> -    int old_prio; >>>>> +    int old_prio, ret; >>>>>       struct rq_flags rf; >>>>>       struct rq *rq; >>>>> @@ -6913,6 +6945,9 @@ void set_user_nice(struct task_struct *p, >>>>> long nice) >>>>>        */ >>>>>       p->sched_class->prio_changed(rq, p, old_prio); >>>>> +    ret = atomic_notifier_call_chain(&user_nice_notifier_list, >>>>> nice, p); >>>>> +    WARN_ON_ONCE(ret != NOTIFY_DONE); >>>>> + >>>>>   out_unlock: >>>>>       task_rq_unlock(rq, p, &rf); >>>>>   } >>>> >>>> No, we're not going to call out to exported, and potentially unbounded, >>>> functions under scheduler locks. >>> >>> Agreed, that's another good point why it is even more hairy, as I have >>> generally alluded in the cover letter. >>> >>> Do you have any immediate thoughts on possible alternatives? >>> >>> Like for instance if I did a queue_work from set_user_nice and then ran >>> a notifier chain async from a worker? I haven't looked at yet what >>> repercussion would that have in terms of having to cancel the pending >>> workers when tasks exit. I can try and prototype that and see how it >>> would look. >> >> Hm or I simply move calling the notifier chain to after task_rq_unlock? That >> would leave it run under the tasklist lock so probably still quite bad. > > Hmm? That's for normalize_rt_tasks() only, right? Just don't have it > call the notifier in that special case (that's a magic sysrq thing > anyway). You mean my talk about tasklist_lock? No, it is also on the syscall part I am interested in as well. Call chain looks like this: sys_setpriority() { ... rcu_read_lock(); read_lock(&tasklist_lock); ... set_one_prio() set_user_nice() { ... task_rq_lock(); -> my notifier from this RFC [1] task_rq_unlock(); -> I can move the notifier here for _some_ improvement [2] } ... read_unlock(&tasklist_lock); rcu_read_unlock(); } So this RFC had the notifier call chain at [1], which I understood was the thing you initially pointed was horrible, being under a scheduler lock. I can trivially move it to [2] but that still leaves it under the tasklist lock. I don't have a good feel how much better that would be. If not good enough then I will look for a smarter solution with less opportunity for global impact. Regards, Tvrtko