Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp870124pxb; Tue, 1 Feb 2022 12:07:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJxNrBdtWZmmqIaPHRg4gMCwqUhcdbR7amXjm5sey4vsEPYpNDwQVBB8zTPKmQomIprkGBL5 X-Received: by 2002:a05:6a00:1a86:: with SMTP id e6mr26937241pfv.2.1643746039770; Tue, 01 Feb 2022 12:07:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643746039; cv=none; d=google.com; s=arc-20160816; b=Oe51ArQjGjv118yyuf+rjgKqtPa4DGqNfulyslEylzC5BNmUmsuHdWZF70pIzb1mJx FhcbyHHWLSnm++KTWRJOnaruuQLMFM/5Y890yJYUxbkBmVPzYEKzntSfhBtIGBgxTcyj +q5tOMrlEQiyknM7iXxxHW92FdVyOaQjay+M+xqoQohncdl0a++bBxnGB0AfSUH0mhDT W+dMShDgPxKwbxeXdSloYpqkr53abdBtAkU/oZkHtAMsqB5yGmSTmXc4pmP2oquVs3/n 55oB5ZxnJ6P/mbbSieE2uG/IYIiaUWR/XBz4hktJQWbuS7U5RCwgYl5ZveALrhIGC0X7 sYUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=C5kcnAwycrzXVpZ5NmHXtLlvrmbZAoQkJ2ajySwR2RE=; b=0+7dTxlH919O419Zl693asPVO5b+ZBzFN7oAfXGS5ntmEicYj6WmPSHDpXWAGgtNar 2PDrlaKFfQq79iFcmfdV5TkMqTb0LJpRFRyH5TqNYaV4y+rS7ftw/va3Tu1kVwRcQoB5 EeJ/sxFO8ilGYs1XGX5rD5jugDVW0ChwGnVOU0EcZ8Vezg10tb8qCzETa2VZhE8J7zbI r6pV+UEcg+Yh5/Gz+My5wKDCUA9N/6aB2UtzYoPjW6ImxrzasldQDMjhLVonTTkdKYbb dKph6a3u+/ME7auTXqbw3v3czphZ4UjBFOuucs4iwDF5GBuindtkeKlJMW5mk4HeK3uS pg7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NDwKKpCt; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l190si16595476pge.482.2022.02.01.12.07.06; Tue, 01 Feb 2022 12:07:19 -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=@linuxfoundation.org header.s=korg header.b=NDwKKpCt; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244565AbiAaLYH (ORCPT + 99 others); Mon, 31 Jan 2022 06:24:07 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:34474 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359668AbiAaLO7 (ORCPT ); Mon, 31 Jan 2022 06:14:59 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D40A9B82A5D; Mon, 31 Jan 2022 11:14:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16C84C340E8; Mon, 31 Jan 2022 11:14:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643627697; bh=PkJT3SYvfU8qtA6Tszre4miU+PS5+gAEXM9RioVyluA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NDwKKpCtSdZb0jH2juVxPlS+CMUdq/hxCeRa2HooGNxGWlHX0TCdHR0VUl514RWcS ZMu7w1YPQkAZSnNt/3H6Ykk7mnx1jDV8i69/FrH5HtSuylmuw6QZ1KR9lmHpnbRW3R NSZf6xkOTghbtglAqbUmpCBcHSNI2RBxeUHQCJwk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Suren Baghdasaryan , kernel test robot , Johannes Weiner , Andrew Morton , Linus Torvalds Subject: [PATCH 5.15 167/171] psi: fix "defined but not used" warnings when CONFIG_PROC_FS=n Date: Mon, 31 Jan 2022 11:57:12 +0100 Message-Id: <20220131105235.668444158@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220131105229.959216821@linuxfoundation.org> References: <20220131105229.959216821@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suren Baghdasaryan commit 44585f7bc0cb01095bc2ad4258049c02bbad21ef upstream. When CONFIG_PROC_FS is disabled psi code generates the following warnings: kernel/sched/psi.c:1364:30: warning: 'psi_cpu_proc_ops' defined but not used [-Wunused-const-variable=] 1364 | static const struct proc_ops psi_cpu_proc_ops = { | ^~~~~~~~~~~~~~~~ kernel/sched/psi.c:1355:30: warning: 'psi_memory_proc_ops' defined but not used [-Wunused-const-variable=] 1355 | static const struct proc_ops psi_memory_proc_ops = { | ^~~~~~~~~~~~~~~~~~~ kernel/sched/psi.c:1346:30: warning: 'psi_io_proc_ops' defined but not used [-Wunused-const-variable=] 1346 | static const struct proc_ops psi_io_proc_ops = { | ^~~~~~~~~~~~~~~ Make definitions of these structures and related functions conditional on CONFIG_PROC_FS config. Link: https://lkml.kernel.org/r/20220119223940.787748-3-surenb@google.com Fixes: 0e94682b73bf ("psi: introduce psi monitor") Signed-off-by: Suren Baghdasaryan Reported-by: kernel test robot Acked-by: Johannes Weiner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- kernel/sched/psi.c | 79 +++++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 38 deletions(-) --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -1082,44 +1082,6 @@ int psi_show(struct seq_file *m, struct return 0; } -static int psi_io_show(struct seq_file *m, void *v) -{ - return psi_show(m, &psi_system, PSI_IO); -} - -static int psi_memory_show(struct seq_file *m, void *v) -{ - return psi_show(m, &psi_system, PSI_MEM); -} - -static int psi_cpu_show(struct seq_file *m, void *v) -{ - return psi_show(m, &psi_system, PSI_CPU); -} - -static int psi_open(struct file *file, int (*psi_show)(struct seq_file *, void *)) -{ - if (file->f_mode & FMODE_WRITE && !capable(CAP_SYS_RESOURCE)) - return -EPERM; - - return single_open(file, psi_show, NULL); -} - -static int psi_io_open(struct inode *inode, struct file *file) -{ - return psi_open(file, psi_io_show); -} - -static int psi_memory_open(struct inode *inode, struct file *file) -{ - return psi_open(file, psi_memory_show); -} - -static int psi_cpu_open(struct inode *inode, struct file *file) -{ - return psi_open(file, psi_cpu_show); -} - struct psi_trigger *psi_trigger_create(struct psi_group *group, char *buf, size_t nbytes, enum psi_res res) { @@ -1278,6 +1240,45 @@ __poll_t psi_trigger_poll(void **trigger return ret; } +#ifdef CONFIG_PROC_FS +static int psi_io_show(struct seq_file *m, void *v) +{ + return psi_show(m, &psi_system, PSI_IO); +} + +static int psi_memory_show(struct seq_file *m, void *v) +{ + return psi_show(m, &psi_system, PSI_MEM); +} + +static int psi_cpu_show(struct seq_file *m, void *v) +{ + return psi_show(m, &psi_system, PSI_CPU); +} + +static int psi_open(struct file *file, int (*psi_show)(struct seq_file *, void *)) +{ + if (file->f_mode & FMODE_WRITE && !capable(CAP_SYS_RESOURCE)) + return -EPERM; + + return single_open(file, psi_show, NULL); +} + +static int psi_io_open(struct inode *inode, struct file *file) +{ + return psi_open(file, psi_io_show); +} + +static int psi_memory_open(struct inode *inode, struct file *file) +{ + return psi_open(file, psi_memory_show); +} + +static int psi_cpu_open(struct inode *inode, struct file *file) +{ + return psi_open(file, psi_cpu_show); +} + static ssize_t psi_write(struct file *file, const char __user *user_buf, size_t nbytes, enum psi_res res) { @@ -1392,3 +1393,5 @@ static int __init psi_proc_init(void) return 0; } module_init(psi_proc_init); + +#endif /* CONFIG_PROC_FS */