Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2775925pxb; Sat, 6 Feb 2021 07:22:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJ3Z332pFhWRqVSVsx9IAgK9A/yh99wpvPH5Cp21yvsFGuYPXgHw2e9yBIqDnDJQKr1xMp X-Received: by 2002:a17:906:4cca:: with SMTP id q10mr9165789ejt.379.1612624963934; Sat, 06 Feb 2021 07:22:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612624963; cv=none; d=google.com; s=arc-20160816; b=QiklJUwa7qJPE2AIDrQ2Zr0cucoUTcyzzL/OrPLAFMBQAU8GVzpFhjUR2IHpuQ5PaZ VOmwuQsuhxumKs6C8q3mog0o5Z6eC67Foy5PraK50S9QLMdpwEUfXUN6dX3NHrYHtPjM F7e4KjHhSHz6u0/aXdzRcTrGGaUJKk/lCwvHZyrZbjkVeZrA9vQBD/KaCu0cVwN9tT1M o9P6KVPfNoaywzXB42bNApbywfDl/7T7YZ2KP0/oHoX71V3Q7TBD7cHVHN6wpjDejU1p vTk5UHrYq2oFKc/YlXxCGJ5wxfO2DHx6twyajeKQScacib80pwqAvrpApFOJv9dpwcD2 k39Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1fKZa5ef0f/JsVVxwPS0Mh8EDmKSue5flkLbzWhoGFo=; b=scVq2j9hclVZl+2qE17uMUgxF8CsPmIPjueNUF5nlcbSH6TId0D+lG1uDiUxI+tAxx fS2Qr6DuPWODWcUktZ4FCDAcsIlHrAjejHCKiLachlSKhKA87faq0c7fTb89Kd4PU+j5 KBhJXBawWoCRoGlWkJh2qxO1tFxAjVXv8N1IO/rXzCajjH6p5sEf/QfSalRSNDlvODPp hEnaAbyaCKkFt5p2/qVVDDbq9HZIhfs5Ts4wtlPuiUXoApdqaPRmJ1rMg74Mt5ioPk1g Wy6oYJQpPOy8Qjc7wvPi+VcVMu0W3KmUzgkNnuSabSOWdCrZVhMMhzlgRJoKVaQqtOOc ewRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gewUvIBf; 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 z6si5244569edr.441.2021.02.06.07.22.18; Sat, 06 Feb 2021 07:22:43 -0800 (PST) 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=gewUvIBf; 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 S230192AbhBFPVg (ORCPT + 99 others); Sat, 6 Feb 2021 10:21:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229586AbhBFPVf (ORCPT ); Sat, 6 Feb 2021 10:21:35 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11789C06174A for ; Sat, 6 Feb 2021 07:20:55 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id i8so17688686ejc.7 for ; Sat, 06 Feb 2021 07:20:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=1fKZa5ef0f/JsVVxwPS0Mh8EDmKSue5flkLbzWhoGFo=; b=gewUvIBfuJ12n1zR6WfvJXluAVgtkbZhNYVrfF5HLgH+2LyFsYnDUVvsT5Y9Do2Sto XIOsDCZKut6H2gcpnvsZHXXwWadaXtUq0gqn8QpOEDGYkS7XocZzz2EHqeK4bVatTCgH 7XmSDlLHuKL0DwGvnWpyyjlSvG6KScH5RhNPU4wfBTW7b2PiVmehRtSJgIimEgnS/yu0 gprFfEm77NL59+g+nDC04iWSYkICkqqqVMWzTLJTJBMF2dUVk5AzXkbwORaSY3kB57m3 ZyaeXHH9HUpl0lUN3k0QIauxqoIXHGKSq20gkQFZ1JSAUvIY/kY7DJ6c73A9PsyWiH7q gzdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=1fKZa5ef0f/JsVVxwPS0Mh8EDmKSue5flkLbzWhoGFo=; b=Q/QbbDdIostqRL1gvmYFYKALp3USgJDEUxtNbQ/W84Se1tLIY6wtMxw+8eAczGGmky YHFq7w3j6ozqBlUhwsPKcEvQ2YfoGHOu1WDvpcm6c35OtfEe52KmfdZ2hYdQK5y3dVDK AQ3wkpCNhIRDKs11/IVp7zNqePtpuZjHdlzYPY2gAuQdELOBkK6szHcMRCszvX40Cdzp K4eoVm8Nkxbrfb0D8freohN4/WGz0xT19P4AbyjNCf4vDauzL1X2TwpPt1wY0s3JRoRo EIMfgeoxgYMY1bYdYSZWkTqABLTJjGyE7++K8p1HMataHzID0orzXrl1lgh+R5M4TR2r 4+jw== X-Gm-Message-State: AOAM532BsJuCinWOglzwlYgZ3OUjYptXSTf+wUOA56NYFnyZnoKkMeqp +6kCS816q8Nfff2nyKRg3g== X-Received: by 2002:a17:906:3685:: with SMTP id a5mr9173646ejc.544.1612624853870; Sat, 06 Feb 2021 07:20:53 -0800 (PST) Received: from localhost.localdomain ([46.53.252.141]) by smtp.gmail.com with ESMTPSA id f6sm2842098edr.72.2021.02.06.07.20.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Feb 2021 07:20:53 -0800 (PST) Date: Sat, 6 Feb 2021 18:20:51 +0300 From: Alexey Dobriyan To: mingo@redhat.com, peterz@infradead.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 2/5] sched: make nr_running() return 32-bit Message-ID: <20210206152051.GB487103@localhost.localdomain> References: <20210206151832.GA487103@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210206151832.GA487103@localhost.localdomain> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Creating 2**32 tasks to run is impossible due to futex pid limits and wasteful anyway. Nobody have done it. Bring nr_running() into 32-bit world to save on REX prefixes. 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(-) --- 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 %d/%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]), --- a/fs/proc/stat.c +++ b/fs/proc/stat.c @@ -200,7 +200,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, --- 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); --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4336,9 +4336,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;