Revision 5501e9229a80d95a1ea68609f44c447a75d23ed5 authored by Adrian Hunter on 07 January 2021, 17:41:59 UTC, committed by Arnaldo Carvalho de Melo on 15 January 2021, 20:28:27 UTC
In some cases, the number of cpus (nr_cpus_online) is confused with the
maximum cpu number (nr_cpus_avail), which results in the error in the
example below:

Example on system with 8 cpus:

 Before:
   # echo 0 > /sys/devices/system/cpu/cpu2/online
   # ./perf record --kcore -e intel_pt// taskset --cpu-list 7 uname
   Linux
   [ perf record: Woken up 1 times to write data ]
   [ perf record: Captured and wrote 0.147 MB perf.data ]
   # ./perf script --itrace=e
   Requested CPU 7 too large. Consider raising MAX_NR_CPUS
   0x25908 [0x8]: failed to process type: 68 [Invalid argument]

 After:
   # ./perf script --itrace=e
   #

Fixes: 8c7274691f0d ("perf machine: Replace MAX_NR_CPUS with perf_env::nr_cpus_online")
Fixes: 7df4e36a4785 ("perf session: Replace MAX_NR_CPUS with perf_env::nr_cpus_online")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Tested-by: Kan Liang <kan.liang@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: stable@vger.kernel.org
Link: http://lore.kernel.org/lkml/20210107174159.24897-1-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent a1bf230
Raw File
blk-pm.h
/* SPDX-License-Identifier: GPL-2.0 */

#ifndef _BLOCK_BLK_PM_H_
#define _BLOCK_BLK_PM_H_

#include <linux/pm_runtime.h>

#ifdef CONFIG_PM
static inline int blk_pm_resume_queue(const bool pm, struct request_queue *q)
{
	if (!q->dev || !blk_queue_pm_only(q))
		return 1;	/* Nothing to do */
	if (pm && q->rpm_status != RPM_SUSPENDED)
		return 1;	/* Request allowed */
	pm_request_resume(q->dev);
	return 0;
}

static inline void blk_pm_mark_last_busy(struct request *rq)
{
	if (rq->q->dev && !(rq->rq_flags & RQF_PM))
		pm_runtime_mark_last_busy(rq->q->dev);
}

static inline void blk_pm_requeue_request(struct request *rq)
{
	lockdep_assert_held(&rq->q->queue_lock);

	if (rq->q->dev && !(rq->rq_flags & RQF_PM))
		rq->q->nr_pending--;
}

static inline void blk_pm_add_request(struct request_queue *q,
				      struct request *rq)
{
	lockdep_assert_held(&q->queue_lock);

	if (q->dev && !(rq->rq_flags & RQF_PM))
		q->nr_pending++;
}

static inline void blk_pm_put_request(struct request *rq)
{
	lockdep_assert_held(&rq->q->queue_lock);

	if (rq->q->dev && !(rq->rq_flags & RQF_PM))
		--rq->q->nr_pending;
}
#else
static inline int blk_pm_resume_queue(const bool pm, struct request_queue *q)
{
	return 1;
}

static inline void blk_pm_mark_last_busy(struct request *rq)
{
}

static inline void blk_pm_requeue_request(struct request *rq)
{
}

static inline void blk_pm_add_request(struct request_queue *q,
				      struct request *rq)
{
}

static inline void blk_pm_put_request(struct request *rq)
{
}
#endif

#endif /* _BLOCK_BLK_PM_H_ */
back to top