From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D1B9367B7D for ; Tue, 19 May 2026 19:45:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779219931; cv=none; b=n9VNgbOJSHosAmJ1MpSWP77oTFpfC06KeNT9U2znQ4bdHvE+KzzyunTVP24vCef4/0l/0pFhpIhXX2eX/KByNeFME1P8QghBizckVsoTN6QwsCxK5P7jNi6j666KMwZOPO6csoa45o5anjtYvgqPI2cosLsLP8HFZvWSS5zwRC8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779219931; c=relaxed/simple; bh=nf3d6Th/qqcFPA3j+0FA/cKyNhD0kVORFLgt2PalDbc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ee2HR71rTMqPmO6u7km2ASbu8o6ZEvW+6hLJghkwthXXV49mmDpx75gn10FmGw+g/to63h1y3DwIx1fneBUeb+vllr+SwcSvu3BUgXxXEFr9F24DoChjFaW2xFXhiEY7ultDHnmeNHHwebdzmSF8HMq4D71lbw9ryrVHrUH2Qwg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=iB+bjYb8; arc=none smtp.client-ip=209.85.208.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iB+bjYb8" Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-38e800deae4so40987981fa.0 for ; Tue, 19 May 2026 12:45:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779219928; x=1779824728; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=i8n4g8DtMbilWmfrS0Iblc6XB8Z+tIb+ktHpUGgo0p4=; b=iB+bjYb8vH7qT64UYpyBHdkiBxhsBeR2vVmkqMoCz9D3IHkpnd4Q+XvSNl0Wc1u63s i9Qj+VYYuB/QQEb2Z8qFQgmcsSxvWmvzC3vJYbfZ4dKRV1n5AdvpAWOQ7foBsCuk/Fjv my7STpRyWTfXLSitSMC1LfLaHJOLGM5sCahIjtaKihG9bd3X+v263MNiHEuIMRVZLhfb CFv9W07mk9vb4tpRyG3rmO/9rd8Zsg/660aL9vZn/u1atRrL90JETRIbOywDTbJv+sc/ n/OZHjVBQ7HVpyFQE3Uphi4chRYeBzu8y6nbFXTlogqLxtb+wLd9lxoA2lHZqlYbQ2kj 6jdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779219928; x=1779824728; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=i8n4g8DtMbilWmfrS0Iblc6XB8Z+tIb+ktHpUGgo0p4=; b=AAGPhUreIIgzgakfQ7ADtceyx5iFUzsqVEZ2+b8W3cLr1jXgl1Pzl9RAuSunXHx9xa Yef8a5XH2xQ09pPf/jD1vDyFlGYyfBVMw7U1TBfQmQWL69f0eMkxzmnmJAmVb2er9NCl 50uzgnzfFbHOorBFG+D59dBEGQnKfz9/icDFjHt2lRsrYunixG+Nqo3ZS+Nm36yDL5JC BYLWEBC9jD4z08UCfYFtGUZic6fcu6dEgP16lJnmCbrIfaB41jCN1JNsU1sL2BT4weA0 q2/H/XDDs9nb8hNAalQ1o2ZPDi92rZP9BWsPgcazKdRNJ83C1J/3jrcB3k7dVy89nGvG OiAQ== X-Forwarded-Encrypted: i=1; AFNElJ8XKiIPuLTFI9VTlhGSZ+gVL1knVzQ1D7M75smIGZ38GBZfMwN6glnHBzI9OR9n3Nzn5MEE9K9DdBITcLA=@vger.kernel.org X-Gm-Message-State: AOJu0YxQD/u1OjUG5+y7bkRrEZiqzOaQa6GC5+u76oEjMrkJ+CIrQIB9 LCrYybqEpR/O6Q6/9zbRqR2lFwWYPf8QE63zeObluRdxtUqlI36RIJ2y X-Gm-Gg: Acq92OGVQS0dzKwg6Q2UsFY+jehxmshYQWYnBgmorvI6jcq+11km7fTSh7Dn89iPxt3 KCGURXlTaVRM+dOOeQLBMlePQ4sMbkVhDoVSOEnJcQb6LuXFENd/i9dDkEqFLxX+HHlPnPQqzzk vCM8pyo/NKaitnfS4VrM7TOdKkSU9yNf8fMZ93w+Dvx1HSkk/rncZYoTJZoNqNX/BqF6RaYzg7i XYUxY2xlJDspowC/+OzkYB0fwqp6QdD6+leAYl9ugYEkc34RkJbsynwjMzVcibJyDXO7sEuZHTa dFhDyjfKsWqcx3+X/nBNDVEAOjhV0WDeeyzLkgs4Macwhw1gCcOishd7Lfhutvj2KfIPw5CjkEi qplSOMUceqnHMTsZ4lK5cPM4TjM0lx+Hmhg4213PoC6yl6qyuhjXpBQRFNto8VhT1QE1obfRrC9 qnMR/UC4fdzhgklFKgmyoFsqZwtA== X-Received: by 2002:a2e:9059:0:b0:38e:58c7:cd1 with SMTP id 38308e7fff4ca-39561dc13c1mr44953141fa.21.1779219927559; Tue, 19 May 2026 12:45:27 -0700 (PDT) Received: from localhost.localdomain ([2001:9b1:d5a0:a500::24b]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-3958827ec3fsm23558761fa.9.2026.05.19.12.45.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2026 12:45:27 -0700 (PDT) From: "Uladzislau Rezki (Sony)" To: "Paul E . McKenney" , Joel Fernandes , Frederic Weisbecker , Boqun Feng Cc: RCU , LKML , Uladzislau Rezki Subject: [PATCH -next v2 02/11] torture: Add torture_sched_set_normal() for user-specified nice values Date: Tue, 19 May 2026 21:45:15 +0200 Message-ID: <20260519194524.158515-3-urezki@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260519194524.158515-1-urezki@gmail.com> References: <20260519194524.158515-1-urezki@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Paul E. McKenney" This new torture_sched_set_normal() function clamps the nice value at the MIN_NICE..MAX_NICE limits, splatting it these limits are exceeded. It then invokes sched_set_normal() to set the new value. This prevents more difficult-to-debug failures within the scheduler. Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- include/linux/torture.h | 1 + kernel/torture.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/linux/torture.h b/include/linux/torture.h index 1b59056c3b18..c9b47d138302 100644 --- a/include/linux/torture.h +++ b/include/linux/torture.h @@ -129,6 +129,7 @@ void _torture_stop_kthread(char *m, struct task_struct **tp); #else #define torture_preempt_schedule() do { } while (0) #endif +void torture_sched_set_normal(struct task_struct *t, int nice); #if IS_ENABLED(CONFIG_RCU_TORTURE_TEST) || IS_MODULE(CONFIG_RCU_TORTURE_TEST) || IS_ENABLED(CONFIG_LOCK_TORTURE_TEST) || IS_MODULE(CONFIG_LOCK_TORTURE_TEST) long torture_sched_setaffinity(pid_t pid, const struct cpumask *in_mask, bool dowarn); diff --git a/kernel/torture.c b/kernel/torture.c index 62c1ac777694..77cb3589b19f 100644 --- a/kernel/torture.c +++ b/kernel/torture.c @@ -972,3 +972,19 @@ void _torture_stop_kthread(char *m, struct task_struct **tp) *tp = NULL; } EXPORT_SYMBOL_GPL(_torture_stop_kthread); + +/* + * Set the specified task's niceness value, saturating at limits. + * Saturating noisily, but saturating. + */ +void torture_sched_set_normal(struct task_struct *t, int nice) +{ + int realnice = nice; + + if (WARN_ON_ONCE(realnice > MAX_NICE)) + realnice = MAX_NICE; + if (WARN_ON_ONCE(realnice < MIN_NICE)) + realnice = MIN_NICE; + sched_set_normal(t, realnice); +} +EXPORT_SYMBOL_GPL(torture_sched_set_normal); -- 2.47.3