Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4018264ybz; Mon, 20 Apr 2020 13:59:41 -0700 (PDT) X-Google-Smtp-Source: APiQypLL7tym7HyHbioPi8mHdp3ngm2MI1KVdf6c12QCAhj8qL16tEH26pYk1c26CHozLpmIYxkT X-Received: by 2002:a17:906:32c5:: with SMTP id k5mr18564753ejk.107.1587416381107; Mon, 20 Apr 2020 13:59:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587416381; cv=none; d=google.com; s=arc-20160816; b=IWq0qheU6H5X5FUPQUk2GK2q5bVo9t4trhJ20pFxcTvUG7G8UJggZElPcQ7DoInKLg lPa1vVDJ8P+mSdkF0afLgoWmYSEQ1wGhelj5NA6rP5orJ6Fa1wa1VLPkfGFOiYsMD1dj eGDZp8d12KSy6eBlT2eeCHfIdH+HMJbPY8Dz0YmrhMYxYTuT26p1jzHeFbg+8U1b9N8s cRDjDukFRuIfXeddeL8G8zMGToGPHVhpAey9xaap1i5t9nAQPhyqH8YEU/cKKEDwq3Kl SXRhp9vuo9c92h7LL9+KsFGV2fRUAh+6lm73YVQNqaKGgdmVaX2QPVzVkCOxqGYsBTRZ YSWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=pC49c/tGR6tK2Z+rYS1KNFKjC1tBztIhygWmLjD7XLI=; b=MhFkNCcTYin0qOLLjCx2OZfjYv3kG2ZfkmW1DYW7N8MZvIWezy7QzAsc245k+D8/eU 35+FOoOWc7Da2JnWabXGuJPmGMJg/9/A8I7FAIXmrXEdC2CRa5Hdc5Dl5benIIh3zAhg MnjNjLIjkzND8bmnnq4TjIVu0UpdEeTil5EaKR1AD7sMW9r7wZroYYxJa/c53Crjvazc na3heLETGLgSRLIWXEqVUar9tCvS8Wo9nGwr9s3dmZYUwn++kX8tJpQLCR++rem7uicQ 0dzgtdYikr5b7OO4OWxT4q7kS0nbOdAD5xf6r3/JSWCeG8xu5GQPCbPX/KBdx+uZLVV1 ngAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=f1PC9GGb; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e6si427803edc.18.2020.04.20.13.59.11; Mon, 20 Apr 2020 13:59:41 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=f1PC9GGb; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726937AbgDTU6K (ORCPT + 99 others); Mon, 20 Apr 2020 16:58:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725897AbgDTU6J (ORCPT ); Mon, 20 Apr 2020 16:58:09 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40DA9C061A0C; Mon, 20 Apr 2020 13:58:09 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id j2so13917756wrs.9; Mon, 20 Apr 2020 13:58:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pC49c/tGR6tK2Z+rYS1KNFKjC1tBztIhygWmLjD7XLI=; b=f1PC9GGbwevBHseC3LNTYWokCHtjeXFgp+JLbN/hCndazXoYtl/CCNswU0vAkLGaJy 0GqKKEvvJFTKwJqgBa16fnvDZmKRG9U6e6MucwXA9eZuvcou8TDCZdfbsp62pczdV9Nb 9JgMS4g2ZxSdRUGSGzzt1cUk87Jn5pCvBxNs25A/eo+fGpsSWC5cTQ5720M09OcW79bA kbfB2EJYcq8oyvn44VCavykzL+/JBr2BIve1zboxJcwog/bW+M5AcGATmxggfZzXKwPN hi4qQWZHrCUiezvvFpcL0mNxACk3x1FFosxq4oo6kRljuxdFByZUXFISKNbgPeqoyFZv cx4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pC49c/tGR6tK2Z+rYS1KNFKjC1tBztIhygWmLjD7XLI=; b=p2mI5M/YW3C3CsRl/NePoEDzXKaGNat/PhdhicuWFRmIfAZP7hdPykWN1DclILmaYG j1A/b4a+OSTSgGA24bWBHhBvJa7DEZQwbmhvP2duzapT/+22CENMa8p5ZJgSQhfPT+aC FlIYALZiI4TXS+qbrMnXiQeQKWwqUfpWOmAwuzTPe/EfSIkn+q5gge0BF6uQixPpAbwQ SQkTf3SCVgFSD87Hg0VWC8aNxLhtZbU64JGkDgyQUV1Eemceelw3nw2vHOVPvWMlT77U +w7f0XWfFqTBliidOtzVlQH57zuZ5tSOMpDt+PJ82d55/CQy1YeyksfoZ7Jw+ntcA5s7 Rm+A== X-Gm-Message-State: AGi0PuZ9IPXD4UQVMxK2QLe69ZO0tTIamr8JzLc88B38Yh4Q2y84ZSfu XJzrVKoj68ZY90Pg3MdK+g== X-Received: by 2002:a5d:6445:: with SMTP id d5mr19970703wrw.373.1587416288001; Mon, 20 Apr 2020 13:58:08 -0700 (PDT) Received: from avx2.telecom.by ([46.53.249.74]) by smtp.gmail.com with ESMTPSA id m8sm863069wrx.54.2020.04.20.13.58.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2020 13:58:07 -0700 (PDT) From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: adobriyan@gmail.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, pmladek@suse.com, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk Subject: [PATCH 01/15] sched: make nr_running() return "unsigned int" Date: Mon, 20 Apr 2020 23:57:29 +0300 Message-Id: <20200420205743.19964-1-adobriyan@gmail.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I don't anyone have been crazy enough to spawn 2^32 threads. It'd require absurd amounts of physical memory, and bump into futex pid limit anyway. Meanwhile save few bits on REX prefixes and some stack space for upcoming print_integer() stuff. And remove "extern" from prototypes while I'm at it. Signed-off-by: Alexey Dobriyan --- fs/proc/loadavg.c | 2 +- fs/proc/stat.c | 2 +- include/linux/sched/stat.h | 2 +- kernel/sched/core.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/proc/loadavg.c b/fs/proc/loadavg.c index 8468baee951d..f32878d9a39f 100644 --- a/fs/proc/loadavg.c +++ b/fs/proc/loadavg.c @@ -16,7 +16,7 @@ static int loadavg_proc_show(struct seq_file *m, void *v) get_avenrun(avnrun, FIXED_1/200, 0); - seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n", + seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %u/%d %d\n", LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]), LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]), LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]), diff --git a/fs/proc/stat.c b/fs/proc/stat.c index 46b3293015fe..93ce344f62a5 100644 --- a/fs/proc/stat.c +++ b/fs/proc/stat.c @@ -197,7 +197,7 @@ static int show_stat(struct seq_file *p, void *v) "\nctxt %llu\n" "btime %llu\n" "processes %lu\n" - "procs_running %lu\n" + "procs_running %u\n" "procs_blocked %lu\n", nr_context_switches(), (unsigned long long)boottime.tv_sec, diff --git a/include/linux/sched/stat.h b/include/linux/sched/stat.h index 568286411b43..f3b86515bafe 100644 --- a/include/linux/sched/stat.h +++ b/include/linux/sched/stat.h @@ -16,7 +16,7 @@ extern unsigned long total_forks; extern int nr_threads; DECLARE_PER_CPU(unsigned long, process_counts); extern int nr_processes(void); -extern unsigned long nr_running(void); +unsigned int nr_running(void); extern bool single_task_running(void); extern unsigned long nr_iowait(void); extern unsigned long nr_iowait_cpu(int cpu); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 3a61a3b8eaa9..d9bae602966c 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3381,9 +3381,9 @@ context_switch(struct rq *rq, struct task_struct *prev, * externally visible scheduler statistics: current number of runnable * threads, total number of context switches performed since bootup. */ -unsigned long nr_running(void) +unsigned int nr_running(void) { - unsigned long i, sum = 0; + unsigned int i, sum = 0; for_each_online_cpu(i) sum += cpu_rq(i)->nr_running; -- 2.24.1