Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2397465rwr; Fri, 21 Apr 2023 08:20:45 -0700 (PDT) X-Google-Smtp-Source: AKy350bI+x3BPSM5gmL9fihUXCVTNY7zqqyEyWkdk7cXIA2OP87f2Be75wJm90W75Y5ypBOT9ZDG X-Received: by 2002:a17:902:f685:b0:1a9:4167:5db7 with SMTP id l5-20020a170902f68500b001a941675db7mr4095243plg.4.1682090444683; Fri, 21 Apr 2023 08:20:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682090444; cv=none; d=google.com; s=arc-20160816; b=wUDg6xaAZgJG1XcRsDbcjfbyW+GoabdgNNSIWZvHujf6uh3TURqrGWvrwkGzTvUqK7 wfLL3bFhWrvs+1VdpZp14UeZ1WrQ0D2cv4gpz+kAQ56Xx9/HW2AKsVU2ychBPn0VyJOy fsI4LJxJoPAvsjJQPhSiu2HtbrfJ3bMGFsOx9pgXWftkZaarHf04wxAj4fjGAnPBiJg7 Z9XOaR5Er5fxKPf3g6ZSLlr4bGs5Cqn1LEbjBzVttU7Sl6Zw8EtW/Ma5ua3RptmziKOU qx3uYCh6ohvSTtH0uq1+monFBOCUi1CMgFWSJwft07kdx04BIdaehis+j8SJ2SXFk0uA UCqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=V6FaXoYkKJvHqik7V6/lHszSapOB8DXJHGCFiR9DavU=; b=hrz18WuzvdjXadc2wiGxM3AxcP5cG0/AOBN8D4aiwaRXUunx5pASJwnaHyqJzK1sr6 g7zCWB9La+mU1CoCV0lAh93K71m7UtwchKRuaXz1rUY0pvk8TqM+o492tIJjbhNHQDKi MZblg+rcMyZaZEqtfEl9nzxUPlNwCVa7pL+U5iK1Zedf9euXsxz4CTFX+cc9HKpQuEKL bF1est7e7huOUfvTwrwLfVE6U5Jy9sGBbHIMCsJtlrxF1hIMOcsUlTJ1WgYlRoi1261X n91zP7sbTkVdEPsXIADW1gKZe9/jGCT+G4g7T/6io7GbgaaUVn5FoDtue2RERAhPQnlq tiJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MY4dMcKP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r18-20020a170902c61200b001a6825fe670si4353946plr.6.2023.04.21.08.20.28; Fri, 21 Apr 2023 08:20:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MY4dMcKP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232480AbjDUPLY (ORCPT + 99 others); Fri, 21 Apr 2023 11:11:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232321AbjDUPLS (ORCPT ); Fri, 21 Apr 2023 11:11:18 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30543D32A for ; Fri, 21 Apr 2023 08:11:03 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-518d325b8a2so2279129a12.0 for ; Fri, 21 Apr 2023 08:11:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1682089862; x=1684681862; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=V6FaXoYkKJvHqik7V6/lHszSapOB8DXJHGCFiR9DavU=; b=MY4dMcKPtmfefWBSJwFWazfdvvF90KDinQ9nmY1Q8uwOjsr0eyWsv7dRFcTtNOKhie /F74SLFHoXkmGe2ljsQiGBYNOXxisfk2szEmRc7IPcFJhFvsm1AljpiagJvlYPNfo7Yb z9DN/4tl2GFtD0Kmf02wqFw98YzVaW65ti8jpyPfegGr7igzJEd5Nu6BhcsQHWItT2kG zVflS859lRQyk+8y6YpsIF4cHBUrcGO0+EMWeuANUoo001Y2EEx/fHwT2CL482Vog+dC KLMTW+NtLcsVl68L6vVJoMywB8g1oVNdjyDYltncfBRr+no5wEEikDenXCU2Y5TJa1LL Vnyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682089862; x=1684681862; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=V6FaXoYkKJvHqik7V6/lHszSapOB8DXJHGCFiR9DavU=; b=gwmehkP+N5evc7EWlW/NdeXXl0UxsLRr6l1BIUTkJnhf6fpM7drThUfHRvtlCAtPLt 7tl5w3OPDfy1Jwntzxb8Xy0rdd79EfG9ZttmhD61MRtZPee1ywuS5z+GsQICpXXAlnAc d5yqT6SO0qeNJnw78ZKuWi0CxOTglUNIbui1XTvJNhu2tkGHrW3ryp8EZAW3mgrK2XXR 0WwWCZ0CXaGXBsTwBJuSOlWIXBphp1bKWr+xmImvfEEFauN1CsYK2WQ+sYpz7zykNCtp 0sJf9SEBeATz/0twFyVRjwyazJdYc/aWrj+jOMyuEHUR1sk+YmN4R2As8/DH8R/xe2zb xtSA== X-Gm-Message-State: AAQBX9dXZjn8X4dJn8IsiH8Mjrr3J3bTqaLcUCBA3PfjSOAkaLBmH8Iq fWUscmpZUhpRcu6PnlAPZxHMP0C+aOcuSgEuFYsgdA== X-Received: by 2002:a17:90b:4f47:b0:236:73d5:82cf with SMTP id pj7-20020a17090b4f4700b0023673d582cfmr5168643pjb.9.1682089862559; Fri, 21 Apr 2023 08:11:02 -0700 (PDT) MIME-Version: 1.0 References: <20230416213406.2966521-1-davidai@google.com> In-Reply-To: From: Vincent Guittot Date: Fri, 21 Apr 2023 17:10:51 +0200 Message-ID: Subject: Re: [RFC PATCH v1] sched/uclamp: Introduce SCHED_FLAG_RESET_UCLAMP_ON_FORK flag To: Saravana Kannan Cc: Dietmar Eggemann , David Dai , Ingo Molnar , Peter Zijlstra , Juri Lelli , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Qais Yousef , Quentin Perret , kernel-team@android.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 20 Apr 2023 at 18:26, Saravana Kannan wrote: > > On Thu, Apr 20, 2023 at 6:44=E2=80=AFAM Vincent Guittot > wrote: > > > > On Thu, 20 Apr 2023 at 11:37, Dietmar Eggemann wrote: > > > > > > On 20/04/2023 03:11, David Dai wrote: > > > > On Tue, Apr 18, 2023 at 10:18=E2=80=AFPM Dietmar Eggemann > > > > wrote: > > > >> > > > > > > > > Hi Dietmar, thanks for your time, > > > > > > > >> On 16/04/2023 23:34, David Dai wrote: > > > >>> A userspace service may manage uclamp dynamically for individual = tasks and > > > >>> a child task will unintentionally inherit a pesudo-random uclamp = setting. > > > >>> This could result in the child task being stuck with a static ucl= amp value > > > >> > > > >> Could you explain this with a little bit more detail? Why isn't th= e > > > >> child task also managed by the userspace service? > > > > > > > > See Qais=E2=80=99 reply that contains more detail on how it=E2=80= =99s being used in > > > > Android. In general, if a dynamic userspace service will adjust ucl= amp > > > > on the fly for a given task, but has no knowledge or control over i= f > > > > or when a task forks. Depending on the timing of the fork, a child > > > > task may inherit a very large or a small uclamp_min or uclamp_max > > > > value. The intent of this patch is to provide more flexibility to t= he > > > > uclamp APIs such that child tasks do not get stuck with a poor ucla= mp > > > > value when spawned while retaining other sched attributes. When > > > > RESET_ON_FORK is set on the parent task, it will reset uclamp value= s > > > > for the child but also reset other sched attributes as well. > > > > > > OK, in this case, why not just change behavior and always reset the > > > uclamp values at fork? > > > > > > Do we anticipate a use-case in which uclamp inheritance would be requ= ired? > > > > > > Let's not over-complicate the sched_[sg]etattr() unnecessarily. > > > > I was about to ask the same question and I'm aligned with Dietmar. > > Use RESET_ON_FORK and set all attributes > > That's racy though. If we have an external service (that's only > responsible for setting uclamp) setting all the attributes, the forked > thread could also be trying to set some of the attributes. Also, how > is this external service going to keep track of all the threads being > forked and set the right attributes for all of them? My assumption was that you didn't use RESET_ON_FORK because there were other attributes that you wanted to keep from parent but it doesn't seem to be the case so use RESET_ON_FORK and if needed the forked thread will set its other attributes > > If it's not considered a UAPI breakage, I'd rather we never inherit uclam= p. > > -Saravana > > > > > > > > > [...] > > > > > > >> Does this issue happen with uclamp mainline or only with Android's > > > >> slightly different version (max- vs. sum aggregation)? > > > > > > > > I=E2=80=99m using the version of uclamp that=E2=80=99s in Linus=E2= =80=99 tree. How uclamp is > > > > aggregated is unrelated to the problem I=E2=80=99m trying to solve = with this > > > > patch. Which is to extend the uclamp APIs to have finer control for > > > > the uclamp inheritance of child tasks. > > > > > > OK, I see.