Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

proportions: add @gfp to init functions

Percpu allocator now supports allocation mask. Add @gfp to
[flex_]proportions init functions so that !GFP_KERNEL allocation masks
can be used with them too.

This patch doesn't make any functional difference.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Peter Zijlstra <peterz@infradead.org>

Tejun Heo 20ae0079 908c7f19

+17 -15
+3 -2
include/linux/flex_proportions.h
··· 10 10 #include <linux/percpu_counter.h> 11 11 #include <linux/spinlock.h> 12 12 #include <linux/seqlock.h> 13 + #include <linux/gfp.h> 13 14 14 15 /* 15 16 * When maximum proportion of some event type is specified, this is the ··· 33 32 seqcount_t sequence; 34 33 }; 35 34 36 - int fprop_global_init(struct fprop_global *p); 35 + int fprop_global_init(struct fprop_global *p, gfp_t gfp); 37 36 void fprop_global_destroy(struct fprop_global *p); 38 37 bool fprop_new_period(struct fprop_global *p, int periods); 39 38 ··· 80 79 raw_spinlock_t lock; /* Protect period and numerator */ 81 80 }; 82 81 83 - int fprop_local_init_percpu(struct fprop_local_percpu *pl); 82 + int fprop_local_init_percpu(struct fprop_local_percpu *pl, gfp_t gfp); 84 83 void fprop_local_destroy_percpu(struct fprop_local_percpu *pl); 85 84 void __fprop_inc_percpu(struct fprop_global *p, struct fprop_local_percpu *pl); 86 85 void __fprop_inc_percpu_max(struct fprop_global *p, struct fprop_local_percpu *pl,
+3 -2
include/linux/proportions.h
··· 12 12 #include <linux/percpu_counter.h> 13 13 #include <linux/spinlock.h> 14 14 #include <linux/mutex.h> 15 + #include <linux/gfp.h> 15 16 16 17 struct prop_global { 17 18 /* ··· 41 40 struct mutex mutex; /* serialize the prop_global switch */ 42 41 }; 43 42 44 - int prop_descriptor_init(struct prop_descriptor *pd, int shift); 43 + int prop_descriptor_init(struct prop_descriptor *pd, int shift, gfp_t gfp); 45 44 void prop_change_shift(struct prop_descriptor *pd, int new_shift); 46 45 47 46 /* ··· 62 61 raw_spinlock_t lock; /* protect the snapshot state */ 63 62 }; 64 63 65 - int prop_local_init_percpu(struct prop_local_percpu *pl); 64 + int prop_local_init_percpu(struct prop_local_percpu *pl, gfp_t gfp); 66 65 void prop_local_destroy_percpu(struct prop_local_percpu *pl); 67 66 void __prop_inc_percpu(struct prop_descriptor *pd, struct prop_local_percpu *pl); 68 67 void prop_fraction_percpu(struct prop_descriptor *pd, struct prop_local_percpu *pl,
+4 -4
lib/flex_proportions.c
··· 34 34 */ 35 35 #include <linux/flex_proportions.h> 36 36 37 - int fprop_global_init(struct fprop_global *p) 37 + int fprop_global_init(struct fprop_global *p, gfp_t gfp) 38 38 { 39 39 int err; 40 40 41 41 p->period = 0; 42 42 /* Use 1 to avoid dealing with periods with 0 events... */ 43 - err = percpu_counter_init(&p->events, 1, GFP_KERNEL); 43 + err = percpu_counter_init(&p->events, 1, gfp); 44 44 if (err) 45 45 return err; 46 46 seqcount_init(&p->sequence); ··· 168 168 */ 169 169 #define PROP_BATCH (8*(1+ilog2(nr_cpu_ids))) 170 170 171 - int fprop_local_init_percpu(struct fprop_local_percpu *pl) 171 + int fprop_local_init_percpu(struct fprop_local_percpu *pl, gfp_t gfp) 172 172 { 173 173 int err; 174 174 175 - err = percpu_counter_init(&pl->events, 0, GFP_KERNEL); 175 + err = percpu_counter_init(&pl->events, 0, gfp); 176 176 if (err) 177 177 return err; 178 178 pl->period = 0;
+5 -5
lib/proportions.c
··· 73 73 #include <linux/proportions.h> 74 74 #include <linux/rcupdate.h> 75 75 76 - int prop_descriptor_init(struct prop_descriptor *pd, int shift) 76 + int prop_descriptor_init(struct prop_descriptor *pd, int shift, gfp_t gfp) 77 77 { 78 78 int err; 79 79 ··· 83 83 pd->index = 0; 84 84 pd->pg[0].shift = shift; 85 85 mutex_init(&pd->mutex); 86 - err = percpu_counter_init(&pd->pg[0].events, 0, GFP_KERNEL); 86 + err = percpu_counter_init(&pd->pg[0].events, 0, gfp); 87 87 if (err) 88 88 goto out; 89 89 90 - err = percpu_counter_init(&pd->pg[1].events, 0, GFP_KERNEL); 90 + err = percpu_counter_init(&pd->pg[1].events, 0, gfp); 91 91 if (err) 92 92 percpu_counter_destroy(&pd->pg[0].events); 93 93 ··· 188 188 189 189 #define PROP_BATCH (8*(1+ilog2(nr_cpu_ids))) 190 190 191 - int prop_local_init_percpu(struct prop_local_percpu *pl) 191 + int prop_local_init_percpu(struct prop_local_percpu *pl, gfp_t gfp) 192 192 { 193 193 raw_spin_lock_init(&pl->lock); 194 194 pl->shift = 0; 195 195 pl->period = 0; 196 - return percpu_counter_init(&pl->events, 0, GFP_KERNEL); 196 + return percpu_counter_init(&pl->events, 0, gfp); 197 197 } 198 198 199 199 void prop_local_destroy_percpu(struct prop_local_percpu *pl)
+1 -1
mm/backing-dev.c
··· 470 470 bdi->write_bandwidth = INIT_BW; 471 471 bdi->avg_write_bandwidth = INIT_BW; 472 472 473 - err = fprop_local_init_percpu(&bdi->completions); 473 + err = fprop_local_init_percpu(&bdi->completions, GFP_KERNEL); 474 474 475 475 if (err) { 476 476 err:
+1 -1
mm/page-writeback.c
··· 1777 1777 writeback_set_ratelimit(); 1778 1778 register_cpu_notifier(&ratelimit_nb); 1779 1779 1780 - fprop_global_init(&writeout_completions); 1780 + fprop_global_init(&writeout_completions, GFP_KERNEL); 1781 1781 } 1782 1782 1783 1783 /**