1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0+
3#
4# Extract the number of CPUs expected from the specified Kconfig-file
5# fragment by checking CONFIG_SMP and CONFIG_NR_CPUS.  If the specified
6# file gives no clue, base the number on the number of idle CPUs on
7# the system.
8#
9# Usage: configNR_CPUS.sh config-frag
10#
11# Copyright (C) IBM Corporation, 2013
12#
13# Authors: Paul E. McKenney <paulmck@linux.ibm.com>
14
15cf=$1
16if test ! -r $cf
17then
18	echo Unreadable config fragment $cf 1>&2
19	exit -1
20fi
21if grep -q '^CONFIG_SMP=n$' $cf
22then
23	echo 1
24	exit 0
25fi
26if grep -q '^CONFIG_NR_CPUS=' $cf
27then
28	grep '^CONFIG_NR_CPUS=' $cf |
29		sed -e 's/^CONFIG_NR_CPUS=\([0-9]*\).*$/\1/'
30	exit 0
31fi
32cpus2use.sh
33