Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1130358ybh; Thu, 16 Jul 2020 04:07:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLbkk37nJFdOCNECkktzL8DHytVF8r5lSTzYhhfnYserCMRh3kIi1NCDKAKl8LAUvbq+gL X-Received: by 2002:a05:6402:94f:: with SMTP id h15mr4008347edz.313.1594897675019; Thu, 16 Jul 2020 04:07:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594897675; cv=none; d=google.com; s=arc-20160816; b=Dwz0NOOzJKHyH44fftFR+IfW/cepUR65aP5ltj89gQegcJIE0ANDG4eNrpJ3iqmNPn 6SqnlHMYodiLLC0Pnf16T4ZV4NTEw6/8q5+bsJC8YnHyg8hzpbhb8q7K9G/qpjWjk9zM ctPFAcMVMaCaNXyUy3iK59KkE4nje2ajJi6MBf2Vuku7yXmfDVHshlzOJxruZJn7VsRt h1tr5zyhbAxc8Dr5gX8qHmNjBxcv8ld2LHt2Z/PcHAsS11nAs/1oCujrF0DNuisVurvK u0zMm9vuWJRtZk0Vp7Je/4r2AYyHDJA7mbNWgGqpRVqL5drt6EJx7lx9OPYUQNDI2bij rERw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=63dKcmkKybZeJ+yVgtC129pJgQXaRhOku9vepLvyuio=; b=L6yucdu4YbbbDwrDkPrXYqNerTvJ/ldGvfl5AlpBpK5rWRaKfkQKBU2d6/dqWweufO SAX+buMSiV1tfGbrQ3DzjyAhkD0pTcEqoW/TJyPRHEbudqJTOzUiDqyAe4v1yAvMezgS Y462dVY/iKNeq5Vn+uF+Z4jimcxjNw3Acpqx5oGIwRI9wS9xdmFOQORyXUtB0luPgzNx PPjSHTTMpYgMY2y0zrrdpBzJTzYL7P81iaaYyPATdfNhj6mxAfhrTeG7kYAfMYiGsDKt Lq7vY5or3ZShVFoYea1afRgd4B3bmbPHcSPavZ7YTcC8E/ca9QQRjcDFJ8tGp8heTY02 0vVQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o9si3361915ejr.243.2020.07.16.04.07.31; Thu, 16 Jul 2020 04:07:55 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727831AbgGPLHV (ORCPT + 99 others); Thu, 16 Jul 2020 07:07:21 -0400 Received: from foss.arm.com ([217.140.110.172]:58178 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726383AbgGPLHV (ORCPT ); Thu, 16 Jul 2020 07:07:21 -0400 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 639B91FB; Thu, 16 Jul 2020 04:07:20 -0700 (PDT) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.195.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D5D6C3F68F; Thu, 16 Jul 2020 04:07:17 -0700 (PDT) From: Qais Yousef To: Ingo Molnar , Peter Zijlstra Cc: Doug Anderson , Qais Yousef , Jonathan Corbet , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Luis Chamberlain , Kees Cook , Iurii Zaikin , Quentin Perret , Valentin Schneider , Patrick Bellasi , Pavan Kondeti , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v7 0/3] sched/uclamp: new sysctl for default RT boost value Date: Thu, 16 Jul 2020 12:03:44 +0100 Message-Id: <20200716110347.19553-1-qais.yousef@arm.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Changes in v7: * Rebase on top of tip/sched/core * Hold task_rq_lock() instead of using RCU. * Better document that changes to p->uclamp_ require task_rq_lock() * Remove smp_{wr}mp() * Hold the the tasklist_lock with smp_mp__after_spinlock() * Add patch 3 which addresses a splat I've seen while testing. static_branch_enable() in __setscheduler_uclamp() was causing it. Remove the call outside of the critical section to fix it. *** v6 cover-letter *** This series introduces a new sysctl_sched_uclamp_util_min_rt_default to control at runtime the default boost value of RT tasks. Full rationale is in patch 1 commit message. v6 has changed the approach taken in v5 [1] and earlier by moving away from the lazy update approach that touched the fast path to a synchronous one that is performed when the write to the procfs entry is done. for_each_process_thread() is used to update all existing RT tasks now. And to handle the race with a concurrent fork() we introduce sched_post_fork() in _do_fork() to ensure a concurrently forked RT tasks gets the right update. To ensure the race condition is handled correctly, I wrote this small (simple!) test program: https://github.com/qais-yousef/uclamp_test.git And ran it on 4core x86 system and 8core big.LITTLE juno-r2 system. From juno-r2 run, 10 iterations each run: Without sched_post_fork() # ./run.sh pid 3105 has 336 but default should be 337 pid 13162 has 336 but default should be 337 pid 23256 has 338 but default should be 339 All forked RT tasks had the correct uclamp.min pid 10638 has 334 but default should be 335 All forked RT tasks had the correct uclamp.min pid 30683 has 335 but default should be 336 pid 8247 has 336 but default should be 337 pid 18170 has 1024 but default should be 334 pid 28274 has 336 but default should be 337 With sched_post_fork() # ./run.sh All forked RT tasks had the correct uclamp.min All forked RT tasks had the correct uclamp.min All forked RT tasks had the correct uclamp.min All forked RT tasks had the correct uclamp.min All forked RT tasks had the correct uclamp.min All forked RT tasks had the correct uclamp.min All forked RT tasks had the correct uclamp.min All forked RT tasks had the correct uclamp.min All forked RT tasks had the correct uclamp.min All forked RT tasks had the correct uclamp.min Thanks -- Qais Yousef [1] https://lore.kernel.org/lkml/20200511154053.7822-1-qais.yousef@arm.com/ CC: Jonathan Corbet CC: Juri Lelli CC: Vincent Guittot CC: Dietmar Eggemann CC: Steven Rostedt CC: Ben Segall CC: Mel Gorman CC: Luis Chamberlain CC: Kees Cook CC: Iurii Zaikin CC: Quentin Perret CC: Valentin Schneider CC: Patrick Bellasi CC: Pavan Kondeti CC: linux-doc@vger.kernel.org CC: linux-kernel@vger.kernel.org CC: linux-fsdevel@vger.kernel.org Qais Yousef (3): sched/uclamp: Add a new sysctl to control RT default boost value Documentation/sysctl: Document uclamp sysctl knobs sched/uclamp: Fix a deadlock when enabling uclamp static key Documentation/admin-guide/sysctl/kernel.rst | 54 +++++++ include/linux/sched.h | 10 +- include/linux/sched/sysctl.h | 1 + include/linux/sched/task.h | 1 + kernel/fork.c | 1 + kernel/sched/core.c | 149 ++++++++++++++++++-- kernel/sysctl.c | 7 + 7 files changed, 208 insertions(+), 15 deletions(-) -- 2.17.1