2005-04-16 15:20:36 -07:00
|
|
|
#ifndef _LINUX_CPUSET_H
|
|
|
|
|
#define _LINUX_CPUSET_H
|
|
|
|
|
/*
|
|
|
|
|
* cpuset interface
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2003 BULL SA
|
2006-03-24 03:16:03 -08:00
|
|
|
* Copyright (C) 2004-2006 Silicon Graphics, Inc.
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <linux/sched.h>
|
|
|
|
|
#include <linux/cpumask.h>
|
|
|
|
|
#include <linux/nodemask.h>
|
2009-04-02 16:57:54 -07:00
|
|
|
#include <linux/mm.h>
|
2014-06-04 16:10:08 -07:00
|
|
|
#include <linux/jump_label.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
#ifdef CONFIG_CPUSETS
|
|
|
|
|
|
2014-06-04 16:10:08 -07:00
|
|
|
extern struct static_key cpusets_enabled_key;
|
|
|
|
|
static inline bool cpusets_enabled(void)
|
|
|
|
|
{
|
|
|
|
|
return static_key_false(&cpusets_enabled_key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline int nr_cpusets(void)
|
|
|
|
|
{
|
|
|
|
|
/* jump label reference count + the top-level cpuset */
|
|
|
|
|
return static_key_count(&cpusets_enabled_key) + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void cpuset_inc(void)
|
|
|
|
|
{
|
|
|
|
|
static_key_slow_inc(&cpusets_enabled_key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void cpuset_dec(void)
|
|
|
|
|
{
|
|
|
|
|
static_key_slow_dec(&cpusets_enabled_key);
|
|
|
|
|
}
|
2006-01-08 01:01:57 -08:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
extern int cpuset_init(void);
|
|
|
|
|
extern void cpuset_init_smp(void);
|
2012-05-24 19:46:55 +05:30
|
|
|
extern void cpuset_update_active_cpus(bool cpu_online);
|
2009-01-07 18:08:45 -08:00
|
|
|
extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask);
|
2012-03-20 15:57:01 +01:00
|
|
|
extern void cpuset_cpus_allowed_fallback(struct task_struct *p);
|
2006-01-08 01:01:55 -08:00
|
|
|
extern nodemask_t cpuset_mems_allowed(struct task_struct *p);
|
2006-12-06 20:31:48 -08:00
|
|
|
#define cpuset_current_mems_allowed (current->mems_allowed)
|
2005-04-16 15:20:36 -07:00
|
|
|
void cpuset_init_current_mems_allowed(void);
|
2008-04-28 02:12:18 -07:00
|
|
|
int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask);
|
2006-01-08 01:01:57 -08:00
|
|
|
|
2014-10-20 15:50:30 +04:00
|
|
|
extern int __cpuset_node_allowed(int node, gfp_t gfp_mask);
|
2006-12-13 00:34:25 -08:00
|
|
|
|
2014-10-20 15:50:30 +04:00
|
|
|
static inline int cpuset_node_allowed(int node, gfp_t gfp_mask)
|
2006-01-08 01:01:57 -08:00
|
|
|
{
|
2014-10-20 15:50:30 +04:00
|
|
|
return nr_cpusets() <= 1 || __cpuset_node_allowed(node, gfp_mask);
|
2006-12-13 00:34:25 -08:00
|
|
|
}
|
|
|
|
|
|
2014-10-20 15:50:30 +04:00
|
|
|
static inline int cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
|
2006-12-13 00:34:25 -08:00
|
|
|
{
|
2014-10-20 15:50:30 +04:00
|
|
|
return cpuset_node_allowed(zone_to_nid(z), gfp_mask);
|
2006-01-08 01:01:57 -08:00
|
|
|
}
|
|
|
|
|
|
2007-10-16 23:25:58 -07:00
|
|
|
extern int cpuset_mems_allowed_intersects(const struct task_struct *tsk1,
|
|
|
|
|
const struct task_struct *tsk2);
|
2006-01-08 01:01:49 -08:00
|
|
|
|
|
|
|
|
#define cpuset_memory_pressure_bump() \
|
|
|
|
|
do { \
|
|
|
|
|
if (cpuset_memory_pressure_enabled) \
|
|
|
|
|
__cpuset_memory_pressure_bump(); \
|
|
|
|
|
} while (0)
|
|
|
|
|
extern int cpuset_memory_pressure_enabled;
|
|
|
|
|
extern void __cpuset_memory_pressure_bump(void);
|
|
|
|
|
|
2008-02-08 04:18:33 -08:00
|
|
|
extern void cpuset_task_status_allowed(struct seq_file *m,
|
|
|
|
|
struct task_struct *task);
|
2014-09-18 16:03:36 +08:00
|
|
|
extern int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns,
|
|
|
|
|
struct pid *pid, struct task_struct *tsk);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-03-24 03:16:03 -08:00
|
|
|
extern int cpuset_mem_spread_node(void);
|
2010-05-26 14:42:49 -07:00
|
|
|
extern int cpuset_slab_spread_node(void);
|
2006-03-24 03:16:03 -08:00
|
|
|
|
|
|
|
|
static inline int cpuset_do_page_mem_spread(void)
|
|
|
|
|
{
|
2014-09-25 09:41:02 +08:00
|
|
|
return task_spread_page(current);
|
2006-03-24 03:16:03 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline int cpuset_do_slab_mem_spread(void)
|
|
|
|
|
{
|
2014-09-25 09:41:02 +08:00
|
|
|
return task_spread_slab(current);
|
2006-03-24 03:16:03 -08:00
|
|
|
}
|
|
|
|
|
|
2007-10-18 23:39:39 -07:00
|
|
|
extern int current_cpuset_is_being_rebound(void);
|
|
|
|
|
|
2008-07-15 04:43:49 -07:00
|
|
|
extern void rebuild_sched_domains(void);
|
|
|
|
|
|
2015-11-05 18:48:05 -08:00
|
|
|
extern void cpuset_print_current_mems_allowed(void);
|
2009-01-06 14:39:01 -08:00
|
|
|
|
2010-05-24 14:32:08 -07:00
|
|
|
/*
|
2014-04-03 14:47:24 -07:00
|
|
|
* read_mems_allowed_begin is required when making decisions involving
|
|
|
|
|
* mems_allowed such as during page allocation. mems_allowed can be updated in
|
|
|
|
|
* parallel and depending on the new value an operation can fail potentially
|
|
|
|
|
* causing process failure. A retry loop with read_mems_allowed_begin and
|
|
|
|
|
* read_mems_allowed_retry prevents these artificial failures.
|
2010-05-24 14:32:08 -07:00
|
|
|
*/
|
2014-04-03 14:47:24 -07:00
|
|
|
static inline unsigned int read_mems_allowed_begin(void)
|
2010-05-24 14:32:08 -07:00
|
|
|
{
|
2015-11-06 16:28:15 -08:00
|
|
|
if (!cpusets_enabled())
|
|
|
|
|
return 0;
|
|
|
|
|
|
2012-03-21 16:34:11 -07:00
|
|
|
return read_seqcount_begin(¤t->mems_allowed_seq);
|
2010-05-24 14:32:08 -07:00
|
|
|
}
|
|
|
|
|
|
2012-03-21 16:34:11 -07:00
|
|
|
/*
|
2014-04-03 14:47:24 -07:00
|
|
|
* If this returns true, the operation that took place after
|
|
|
|
|
* read_mems_allowed_begin may have failed artificially due to a concurrent
|
|
|
|
|
* update of mems_allowed. It is up to the caller to retry the operation if
|
2012-03-21 16:34:11 -07:00
|
|
|
* appropriate.
|
|
|
|
|
*/
|
2014-04-03 14:47:24 -07:00
|
|
|
static inline bool read_mems_allowed_retry(unsigned int seq)
|
2010-05-24 14:32:08 -07:00
|
|
|
{
|
2015-11-06 16:28:15 -08:00
|
|
|
if (!cpusets_enabled())
|
|
|
|
|
return false;
|
|
|
|
|
|
2014-04-03 14:47:24 -07:00
|
|
|
return read_seqcount_retry(¤t->mems_allowed_seq, seq);
|
2010-05-24 14:32:08 -07:00
|
|
|
}
|
|
|
|
|
|
2009-06-16 15:31:49 -07:00
|
|
|
static inline void set_mems_allowed(nodemask_t nodemask)
|
|
|
|
|
{
|
2013-10-07 15:52:00 -07:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
2010-05-24 14:32:08 -07:00
|
|
|
task_lock(current);
|
2013-10-07 15:52:00 -07:00
|
|
|
local_irq_save(flags);
|
2012-03-21 16:34:11 -07:00
|
|
|
write_seqcount_begin(¤t->mems_allowed_seq);
|
2009-06-16 15:31:49 -07:00
|
|
|
current->mems_allowed = nodemask;
|
2012-03-21 16:34:11 -07:00
|
|
|
write_seqcount_end(¤t->mems_allowed_seq);
|
2013-10-07 15:52:00 -07:00
|
|
|
local_irq_restore(flags);
|
2010-05-24 14:32:08 -07:00
|
|
|
task_unlock(current);
|
2009-06-16 15:31:49 -07:00
|
|
|
}
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#else /* !CONFIG_CPUSETS */
|
|
|
|
|
|
2014-06-04 16:10:08 -07:00
|
|
|
static inline bool cpusets_enabled(void) { return false; }
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
static inline int cpuset_init(void) { return 0; }
|
|
|
|
|
static inline void cpuset_init_smp(void) {}
|
|
|
|
|
|
2012-05-24 19:46:55 +05:30
|
|
|
static inline void cpuset_update_active_cpus(bool cpu_online)
|
2010-06-08 21:40:36 +02:00
|
|
|
{
|
|
|
|
|
partition_sched_domains(1, NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-07 18:08:45 -08:00
|
|
|
static inline void cpuset_cpus_allowed(struct task_struct *p,
|
|
|
|
|
struct cpumask *mask)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2009-03-30 22:05:15 -06:00
|
|
|
cpumask_copy(mask, cpu_possible_mask);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
2012-03-20 15:57:01 +01:00
|
|
|
static inline void cpuset_cpus_allowed_fallback(struct task_struct *p)
|
2010-03-15 10:10:27 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-08 01:01:55 -08:00
|
|
|
static inline nodemask_t cpuset_mems_allowed(struct task_struct *p)
|
|
|
|
|
{
|
|
|
|
|
return node_possible_map;
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-12 13:51:24 -08:00
|
|
|
#define cpuset_current_mems_allowed (node_states[N_MEMORY])
|
2005-04-16 15:20:36 -07:00
|
|
|
static inline void cpuset_init_current_mems_allowed(void) {}
|
|
|
|
|
|
2008-04-28 02:12:18 -07:00
|
|
|
static inline int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-20 15:50:30 +04:00
|
|
|
static inline int cpuset_node_allowed(int node, gfp_t gfp_mask)
|
2009-04-02 16:57:54 -07:00
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-20 15:50:30 +04:00
|
|
|
static inline int cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-16 23:25:58 -07:00
|
|
|
static inline int cpuset_mems_allowed_intersects(const struct task_struct *tsk1,
|
|
|
|
|
const struct task_struct *tsk2)
|
2005-09-06 15:18:13 -07:00
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-08 01:01:49 -08:00
|
|
|
static inline void cpuset_memory_pressure_bump(void) {}
|
|
|
|
|
|
2008-02-08 04:18:33 -08:00
|
|
|
static inline void cpuset_task_status_allowed(struct seq_file *m,
|
|
|
|
|
struct task_struct *task)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2006-03-24 03:16:03 -08:00
|
|
|
static inline int cpuset_mem_spread_node(void)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-26 14:42:49 -07:00
|
|
|
static inline int cpuset_slab_spread_node(void)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2006-03-24 03:16:03 -08:00
|
|
|
static inline int cpuset_do_page_mem_spread(void)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline int cpuset_do_slab_mem_spread(void)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-18 23:39:39 -07:00
|
|
|
static inline int current_cpuset_is_being_rebound(void)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-15 04:43:49 -07:00
|
|
|
static inline void rebuild_sched_domains(void)
|
|
|
|
|
{
|
2008-08-29 13:11:41 -07:00
|
|
|
partition_sched_domains(1, NULL, NULL);
|
2008-07-15 04:43:49 -07:00
|
|
|
}
|
|
|
|
|
|
2015-11-05 18:48:05 -08:00
|
|
|
static inline void cpuset_print_current_mems_allowed(void)
|
2009-01-06 14:39:01 -08:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-16 15:31:49 -07:00
|
|
|
static inline void set_mems_allowed(nodemask_t nodemask)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-03 14:47:24 -07:00
|
|
|
static inline unsigned int read_mems_allowed_begin(void)
|
2010-05-24 14:32:08 -07:00
|
|
|
{
|
2012-03-21 16:34:11 -07:00
|
|
|
return 0;
|
2010-05-24 14:32:08 -07:00
|
|
|
}
|
|
|
|
|
|
2014-04-03 14:47:24 -07:00
|
|
|
static inline bool read_mems_allowed_retry(unsigned int seq)
|
2010-05-24 14:32:08 -07:00
|
|
|
{
|
2014-04-03 14:47:24 -07:00
|
|
|
return false;
|
2010-05-24 14:32:08 -07:00
|
|
|
}
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#endif /* !CONFIG_CPUSETS */
|
|
|
|
|
|
|
|
|
|
#endif /* _LINUX_CPUSET_H */
|