Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1324085ybz; Fri, 1 May 2020 20:14:42 -0700 (PDT) X-Google-Smtp-Source: APiQypLPRPHpSJADzxUN8GR3N6oPNYj9j0kqmQIwjyvSGbFJpVXJmMgOy9wyZjOsgWMNUONVjhly X-Received: by 2002:a17:906:1c8a:: with SMTP id g10mr6184014ejh.342.1588389282095; Fri, 01 May 2020 20:14:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588389282; cv=none; d=google.com; s=arc-20160816; b=j/ZWNhtW/QQV//E5dCQ6qHGdLKR35Gpw4Rgo2gCzS4dek0CcWPXsINtgaF5Fv+pR1B Fxs29Kizvlyn0jKudLq+QiczrBVJ/eP5I4gPpBPLmkkiPonBLAfmlVI0kOWW51/d/qUe RonwTPaWrB+u5/dPMKQFhM68Kmj+SpII8Wt/nhOHUWSePp6JdbhGKIt9Tzg7ninqj6qL bqE2lgvHQqEE9jwtKs7/pIRkZ1/h5j2MNt+TTqZDyGLq9bbceskPaN7ubLmES04y3VsE FWdkMQKBuwe3ITDu3J+W/JCudECWc1D8BiK1DhjrZ09BpeEwj9EzL2isjBgQ0BaqCOc3 fpCQ== 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=/b57VmCAdDk9EkEoPvOUcwMVF4gLFIlXAqWazjxs90U=; b=LR4s20hR9+o9Kf+Xnl7SR9Voj/z3Jh1V+9ncskHCwmkf0T0mhZfnHGBQUSvIB1hJv0 hpcps30Orp/ao94OthYrAwDSV1KmAFjBh8f1Hr0g8QXZl4LVJqM3oMsKFP2DDHKUXiHq ra0byAC+3Wn/381/SBiwAs4/fPz6SdxRP3lHsVVApBH62YQ5irGnbNrERhzMzLRSLY/f CN5+bn15nIqyOTf4rQlcUFZtp9Ism9lbrPjtnVyB31nwdthO3AD5nN2v9481FPX3UDMW EDmg4xKmkxgDLNZ0RvPi9zbV4TwL0g1pLTOuwX4U2HgIwXubHNeoD2fCBcfCSa9HOicH KukA== 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 f10si2970636ejb.466.2020.05.01.20.14.18; Fri, 01 May 2020 20:14:42 -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 S1726799AbgEBDKB (ORCPT + 99 others); Fri, 1 May 2020 23:10:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:51888 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726439AbgEBDKB (ORCPT ); Fri, 1 May 2020 23:10:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D5398AEA2; Sat, 2 May 2020 03:09:59 +0000 (UTC) From: Davidlohr Bueso To: akpm@linux-foundation.org Cc: tglx@linutronix.de, peterz@infradead.org, mingo@kernel.org, mgorman@techsingularity.net, bp@suse.de, dave@stgolabs.net, linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: [PATCH] kernel/sys: do not use tasklist_lock to set/get scheduling priorities Date: Fri, 1 May 2020 20:05:39 -0700 Message-Id: <20200502030539.32581-1-dave@stgolabs.net> X-Mailer: git-send-email 2.16.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For both setpriority(2) and getpriority(2) there's really no need to be taking the tasklist_lock at all - for which both share it for the entirety of the syscall. The tasklist_lock does not protect reading/writing the p->static_prio and task lookups are already rcu safe, providing a stable pointer. The following raw microbenchmark improvements on a 40-core box were seen running the stressng-get workload, which pathologically pounds on various syscalls that get information from the kernel. Increasing thread counts of course shows more wins, albeit probably not something that would be seen in a real workload. 5.7.0-rc3 5.7.0-rc3 getpriority-v1 Hmean get-1 3443.65 ( 0.00%) 3314.08 * -3.76%* Hmean get-2 7809.99 ( 0.00%) 8547.60 * 9.44%* Hmean get-4 15498.01 ( 0.00%) 17396.85 * 12.25%* Hmean get-8 28001.37 ( 0.00%) 31137.53 * 11.20%* Hmean get-16 31460.88 ( 0.00%) 40284.35 * 28.05%* Hmean get-32 30036.64 ( 0.00%) 40657.88 * 35.36%* Hmean get-64 31429.86 ( 0.00%) 41021.73 * 30.52%* Hmean get-80 31804.13 ( 0.00%) 39188.55 * 23.22%* Signed-off-by: Davidlohr Bueso --- kernel/sys.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/kernel/sys.c b/kernel/sys.c index d325f3ab624a..12ade1a00a18 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -214,7 +214,6 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval) niceval = MAX_NICE; rcu_read_lock(); - read_lock(&tasklist_lock); switch (which) { case PRIO_PROCESS: if (who) @@ -252,7 +251,6 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval) break; } out_unlock: - read_unlock(&tasklist_lock); rcu_read_unlock(); out: return error; @@ -277,7 +275,6 @@ SYSCALL_DEFINE2(getpriority, int, which, int, who) return -EINVAL; rcu_read_lock(); - read_lock(&tasklist_lock); switch (which) { case PRIO_PROCESS: if (who) @@ -323,7 +320,6 @@ SYSCALL_DEFINE2(getpriority, int, which, int, who) break; } out_unlock: - read_unlock(&tasklist_lock); rcu_read_unlock(); return retval; -- 2.16.4