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

[PATCH] cpuset: don't need to mark cpuset_mems_generation atomic

Drop the atomic_t marking on the cpuset static global
cpuset_mems_generation. Since all access to it is guarded by the global
manage_mutex, there is no need for further serialization of this value.

Signed-off-by: Paul Jackson <pj@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Paul Jackson and committed by
Linus Torvalds
151a4420 8488bc35

+11 -8
+11 -8
kernel/cpuset.c
··· 149 149 } 150 150 151 151 /* 152 - * Increment this atomic integer everytime any cpuset changes its 152 + * Increment this integer everytime any cpuset changes its 153 153 * mems_allowed value. Users of cpusets can track this generation 154 154 * number, and avoid having to lock and reload mems_allowed unless 155 155 * the cpuset they're using changes generation. ··· 163 163 * on every visit to __alloc_pages(), to efficiently check whether 164 164 * its current->cpuset->mems_allowed has changed, requiring an update 165 165 * of its current->mems_allowed. 166 + * 167 + * Since cpuset_mems_generation is guarded by manage_mutex, 168 + * there is no need to mark it atomic. 166 169 */ 167 - static atomic_t cpuset_mems_generation = ATOMIC_INIT(1); 170 + static int cpuset_mems_generation; 168 171 169 172 static struct cpuset top_cpuset = { 170 173 .flags = ((1 << CS_CPU_EXCLUSIVE) | (1 << CS_MEM_EXCLUSIVE)), ··· 880 877 881 878 mutex_lock(&callback_mutex); 882 879 cs->mems_allowed = trialcs.mems_allowed; 883 - cs->mems_generation = atomic_inc_return(&cpuset_mems_generation); 880 + cs->mems_generation = cpuset_mems_generation++; 884 881 mutex_unlock(&callback_mutex); 885 882 886 883 set_cpuset_being_rebound(cs); /* causes mpol_copy() rebind */ ··· 1273 1270 break; 1274 1271 case FILE_SPREAD_PAGE: 1275 1272 retval = update_flag(CS_SPREAD_PAGE, cs, buffer); 1276 - cs->mems_generation = atomic_inc_return(&cpuset_mems_generation); 1273 + cs->mems_generation = cpuset_mems_generation++; 1277 1274 break; 1278 1275 case FILE_SPREAD_SLAB: 1279 1276 retval = update_flag(CS_SPREAD_SLAB, cs, buffer); 1280 - cs->mems_generation = atomic_inc_return(&cpuset_mems_generation); 1277 + cs->mems_generation = cpuset_mems_generation++; 1281 1278 break; 1282 1279 case FILE_TASKLIST: 1283 1280 retval = attach_task(cs, buffer, &pathbuf); ··· 1826 1823 atomic_set(&cs->count, 0); 1827 1824 INIT_LIST_HEAD(&cs->sibling); 1828 1825 INIT_LIST_HEAD(&cs->children); 1829 - cs->mems_generation = atomic_inc_return(&cpuset_mems_generation); 1826 + cs->mems_generation = cpuset_mems_generation++; 1830 1827 fmeter_init(&cs->fmeter); 1831 1828 1832 1829 cs->parent = parent; ··· 1916 1913 struct task_struct *tsk = current; 1917 1914 1918 1915 tsk->cpuset = &top_cpuset; 1919 - tsk->cpuset->mems_generation = atomic_inc_return(&cpuset_mems_generation); 1916 + tsk->cpuset->mems_generation = cpuset_mems_generation++; 1920 1917 return 0; 1921 1918 } 1922 1919 ··· 1935 1932 top_cpuset.mems_allowed = NODE_MASK_ALL; 1936 1933 1937 1934 fmeter_init(&top_cpuset.fmeter); 1938 - top_cpuset.mems_generation = atomic_inc_return(&cpuset_mems_generation); 1935 + top_cpuset.mems_generation = cpuset_mems_generation++; 1939 1936 1940 1937 init_task.cpuset = &top_cpuset; 1941 1938