Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1824184rdb; Mon, 9 Oct 2023 04:22:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEwr//cSuT0CZKTNr2RgzocKfR+xJW+3mUIsJDz5WHaENvf1P1CxJNViJmTXApkhsGNLlFV X-Received: by 2002:a17:903:2309:b0:1c6:2acc:62d7 with SMTP id d9-20020a170903230900b001c62acc62d7mr15441399plh.15.1696850575276; Mon, 09 Oct 2023 04:22:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696850575; cv=none; d=google.com; s=arc-20160816; b=nkZq7eNF1zCjyoBvsPZ6O5yiKTj8teQIMBJWF0jEZJFoEfnzjSyg0EsGn1ulF1KkJv GANIxZB2UyXE1WJ7Q9N66B25YkGhBnlpxKm+NSzMqCXtXMyvIhQyBloibvQPM7Rn6ThK +IeGXLK1ezkDgmZQh30zN/2IkUZtw1bSpDY8rMReW8QOpgiUwE+cYFzMmRUw9Rq8AqlK EXob11nPS1rFmuClYcBXCoaHQe4wJ6vg+QOsXmy2BleJgXn3L7nx7dXFTlTdlwkhZQ6f Wu7oEzL9rRiJd0NsQAPQQ/saExPgne984VeY4GyKLNy+5DBQF9uR3Vjx83AuR2/7e+oB zJzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:mime-version:date :dkim-signature:message-id; bh=p5fKDl+jfEdvEfYRITrazIhSAYorlwXMp+uweVVx3II=; fh=yuUYAWVNHOtNOVXfHbDzOfyhHEjVkUA0VR4N/COjqQA=; b=jJkdxiqrkofbw8e6t9gKdyk6EYoa4Tac6A+PJCrceYzaQKDkLpvHFSGkQyESnlIJiR 2GI+qvh2ycMW9IK9D6nKr5wuQxjoS5LXChpR8OYa8LkGj4/uImXliearprWTV1HyvRow UdvfOy4Vnyt0r9Fjd17lM022/0JXu6LkqISPsvfBDgLev58W3Ict7CO45ETgc3lP+BHb 04nhjKnspjMfS6ngKVkEoMU8PI/5AGhsbNDSCoBvUQuYjbS8T3rdKerybKOnPusgJySE wGla0eh5B/UPsvrZNvM0iNk/IkU5v3+pBe6MwskXt/yFIRrYzHAJh/9rZMlob5y2hILv +OpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="s0oLI/U4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id r20-20020a170902c61400b001bb324569efsi8766648plr.364.2023.10.09.04.22.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 04:22:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="s0oLI/U4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id C1350803B2E1; Mon, 9 Oct 2023 04:22:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346219AbjJILWb (ORCPT + 99 others); Mon, 9 Oct 2023 07:22:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346215AbjJILWa (ORCPT ); Mon, 9 Oct 2023 07:22:30 -0400 Received: from out-193.mta1.migadu.com (out-193.mta1.migadu.com [IPv6:2001:41d0:203:375::c1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6252AB for ; Mon, 9 Oct 2023 04:22:28 -0700 (PDT) Message-ID: <23b7e38b-a5c9-7547-499f-efbf6abfbfe9@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1696850547; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p5fKDl+jfEdvEfYRITrazIhSAYorlwXMp+uweVVx3II=; b=s0oLI/U4+8tULlXdUKag4MRgckBz0xnJxogRrgzIdzby/pEV8oH0pH+EvdragiL9JtuzFo QKXS0G1YoDlOGUapBdgyGtrsHTxDpbL/AQ1bxnpe29TN6j+WtlKq2JkY+c3UDl8vlRS43d SIxfHIHd8U02WjqLEhcje+ttsAqIbEg= Date: Mon, 9 Oct 2023 19:22:19 +0800 MIME-Version: 1.0 Subject: Re: [PATCH] sched/rt: case sysctl_sched_rt_period to integer Content-Language: en-US To: Ingo Molnar Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, linux-kernel@vger.kernel.org References: <20231008021538.3063250-1-yajun.deng@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yajun Deng In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 09 Oct 2023 04:22:53 -0700 (PDT) X-Spam-Level: ** On 2023/10/9 18:38, Ingo Molnar wrote: > * Yajun Deng wrote: > >> proc_dointvec_minmax is for integer, but sysctl_sched_rt_period is an >> unsigned integer. And sysctl_sched_rt_period takes values from 1 to >> INT_MAX, so sysctl_sched_rt_period doesn't have to be an unsigned integer. >> >> Case sysctl_sched_rt_period to integer. Also, change the maximum value >> of sysctl_sched_rt_runtime to sysctl_sched_rt_period. >> >> Signed-off-by: Yajun Deng >> --- >> kernel/sched/rt.c | 6 +++--- >> kernel/sched/sched.h | 2 +- >> 2 files changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c >> index 88fc98601413..76d82a096e03 100644 >> --- a/kernel/sched/rt.c >> +++ b/kernel/sched/rt.c >> @@ -16,7 +16,7 @@ struct rt_bandwidth def_rt_bandwidth; >> * period over which we measure -rt task CPU usage in us. >> * default: 1s >> */ >> -unsigned int sysctl_sched_rt_period = 1000000; >> +int sysctl_sched_rt_period = 1000000; >> >> /* >> * part of the period that we allow rt tasks to run in us. >> @@ -34,7 +34,7 @@ static struct ctl_table sched_rt_sysctls[] = { >> { >> .procname = "sched_rt_period_us", >> .data = &sysctl_sched_rt_period, >> - .maxlen = sizeof(unsigned int), >> + .maxlen = sizeof(int), >> .mode = 0644, >> .proc_handler = sched_rt_handler, >> .extra1 = SYSCTL_ONE, >> @@ -47,7 +47,7 @@ static struct ctl_table sched_rt_sysctls[] = { >> .data = &sysctl_sched_rt_runtime, # added for clarity >> .mode = 0644, >> .proc_handler = sched_rt_handler, >> .extra1 = SYSCTL_NEG_ONE, >> - .extra2 = SYSCTL_INT_MAX, >> + .extra2 = (void *)&sysctl_sched_rt_period, > Yeah, so I suppose this is a good change and desirable, also because > sysctl_sched_rt_period is already an int, and all the calculus around these > figures is 'int' based. So having an 'unsigned int' is indeed confusing and > doesn't encode the true sysctl limit correctly. > > But I don't think the checking is full with this patch applied either: if > sysctl_sched_rt_period is shrunk below the current value of > sysctl_sched_rt_runtime, then sysctl_sched_rt_runtime will stay out of > bounds indefinitely, right? No, 'sysctl_sched_rt_runtime > sysctl_sched_rt_period' in sched_rt_global_validate() will make sure sysctl_sched_rt_period doesn't below sysctl_sched_rt_runtime. > > I guess this comes with the territory of internal sysctls though. > > Thanks, > > Ingo