@@ -584,16 +584,6 @@ do { \
} \
} while (0)
-#define per_cpu_sum(_p) \
-({ \
- typeof(*_p) _ret = 0; \
- \
- int cpu; \
- for_each_possible_cpu(cpu) \
- _ret += *per_cpu_ptr(_p, cpu); \
- _ret; \
-})
-
static inline u64 percpu_u64_get(u64 __percpu *src)
{
return per_cpu_sum(src);
@@ -151,29 +151,19 @@ static struct dentry_stat_t dentry_stat = {
*/
static long get_nr_dentry(void)
{
- int i;
- long sum = 0;
- for_each_possible_cpu(i)
- sum += per_cpu(nr_dentry, i);
+ long sum = per_cpu_sum(&nr_dentry);
return sum < 0 ? 0 : sum;
}
static long get_nr_dentry_unused(void)
{
- int i;
- long sum = 0;
- for_each_possible_cpu(i)
- sum += per_cpu(nr_dentry_unused, i);
+ long sum = per_cpu_sum(&nr_dentry_unused);
return sum < 0 ? 0 : sum;
}
static long get_nr_dentry_negative(void)
{
- int i;
- long sum = 0;
-
- for_each_possible_cpu(i)
- sum += per_cpu(nr_dentry_negative, i);
+ long sum = per_cpu_sum(&nr_dentry_negative);
return sum < 0 ? 0 : sum;
}
@@ -162,4 +162,14 @@ extern phys_addr_t per_cpu_ptr_to_phys(void *addr);
extern unsigned long pcpu_nr_pages(void);
+#define per_cpu_sum(_p) \
+({ \
+ typeof(*(_p)) sum = 0; \
+ int cpu; \
+ \
+ for_each_possible_cpu(cpu) \
+ sum += *per_cpu_ptr(_p, cpu); \
+ sum; \
+})
+
#endif /* __LINUX_PERCPU_H */