Commit ae7a927d authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds

mm: use sysfs_emit for struct kobject * uses

Patch series "mm: Convert sysfs sprintf family to sysfs_emit", v2.

Use the new sysfs_emit family and not the sprintf family.

This patch (of 5):

Use the sysfs_emit function instead of the sprintf family.

Done with cocci script as in commit 3c6bff3c ("RDMA: Convert sysfs
kobject * show functions to use sysfs_emit()")

Link: https://lkml.kernel.org/r/cover.1605376435.git.joe@perches.com
Link: https://lkml.kernel.org/r/9c249215bad6df616ba0410ad980042694970c1b.1605376435.git.joe@perches.comSigned-off-by: default avatarJoe Perches <joe@perches.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a00cda3f
...@@ -164,11 +164,11 @@ static ssize_t enabled_show(struct kobject *kobj, ...@@ -164,11 +164,11 @@ static ssize_t enabled_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf) struct kobj_attribute *attr, char *buf)
{ {
if (test_bit(TRANSPARENT_HUGEPAGE_FLAG, &transparent_hugepage_flags)) if (test_bit(TRANSPARENT_HUGEPAGE_FLAG, &transparent_hugepage_flags))
return sprintf(buf, "[always] madvise never\n"); return sysfs_emit(buf, "[always] madvise never\n");
else if (test_bit(TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG, &transparent_hugepage_flags)) else if (test_bit(TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG, &transparent_hugepage_flags))
return sprintf(buf, "always [madvise] never\n"); return sysfs_emit(buf, "always [madvise] never\n");
else else
return sprintf(buf, "always madvise [never]\n"); return sysfs_emit(buf, "always madvise [never]\n");
} }
static ssize_t enabled_store(struct kobject *kobj, static ssize_t enabled_store(struct kobject *kobj,
...@@ -233,14 +233,18 @@ static ssize_t defrag_show(struct kobject *kobj, ...@@ -233,14 +233,18 @@ static ssize_t defrag_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf) struct kobj_attribute *attr, char *buf)
{ {
if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG, &transparent_hugepage_flags)) if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG, &transparent_hugepage_flags))
return sprintf(buf, "[always] defer defer+madvise madvise never\n"); return sysfs_emit(buf,
"[always] defer defer+madvise madvise never\n");
if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG, &transparent_hugepage_flags)) if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG, &transparent_hugepage_flags))
return sprintf(buf, "always [defer] defer+madvise madvise never\n"); return sysfs_emit(buf,
"always [defer] defer+madvise madvise never\n");
if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_OR_MADV_FLAG, &transparent_hugepage_flags)) if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_OR_MADV_FLAG, &transparent_hugepage_flags))
return sprintf(buf, "always defer [defer+madvise] madvise never\n"); return sysfs_emit(buf,
"always defer [defer+madvise] madvise never\n");
if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG, &transparent_hugepage_flags)) if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG, &transparent_hugepage_flags))
return sprintf(buf, "always defer defer+madvise [madvise] never\n"); return sysfs_emit(buf,
return sprintf(buf, "always defer defer+madvise madvise [never]\n"); "always defer defer+madvise [madvise] never\n");
return sysfs_emit(buf, "always defer defer+madvise madvise [never]\n");
} }
static ssize_t defrag_store(struct kobject *kobj, static ssize_t defrag_store(struct kobject *kobj,
...@@ -298,7 +302,7 @@ static struct kobj_attribute use_zero_page_attr = ...@@ -298,7 +302,7 @@ static struct kobj_attribute use_zero_page_attr =
static ssize_t hpage_pmd_size_show(struct kobject *kobj, static ssize_t hpage_pmd_size_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf) struct kobj_attribute *attr, char *buf)
{ {
return sprintf(buf, "%lu\n", HPAGE_PMD_SIZE); return sysfs_emit(buf, "%lu\n", HPAGE_PMD_SIZE);
} }
static struct kobj_attribute hpage_pmd_size_attr = static struct kobj_attribute hpage_pmd_size_attr =
__ATTR_RO(hpage_pmd_size); __ATTR_RO(hpage_pmd_size);
......
...@@ -2760,7 +2760,7 @@ static ssize_t nr_hugepages_show_common(struct kobject *kobj, ...@@ -2760,7 +2760,7 @@ static ssize_t nr_hugepages_show_common(struct kobject *kobj,
else else
nr_huge_pages = h->nr_huge_pages_node[nid]; nr_huge_pages = h->nr_huge_pages_node[nid];
return sprintf(buf, "%lu\n", nr_huge_pages); return sysfs_emit(buf, "%lu\n", nr_huge_pages);
} }
static ssize_t __nr_hugepages_store_common(bool obey_mempolicy, static ssize_t __nr_hugepages_store_common(bool obey_mempolicy,
...@@ -2833,7 +2833,8 @@ HSTATE_ATTR(nr_hugepages); ...@@ -2833,7 +2833,8 @@ HSTATE_ATTR(nr_hugepages);
* huge page alloc/free. * huge page alloc/free.
*/ */
static ssize_t nr_hugepages_mempolicy_show(struct kobject *kobj, static ssize_t nr_hugepages_mempolicy_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf) struct kobj_attribute *attr,
char *buf)
{ {
return nr_hugepages_show_common(kobj, attr, buf); return nr_hugepages_show_common(kobj, attr, buf);
} }
...@@ -2851,7 +2852,7 @@ static ssize_t nr_overcommit_hugepages_show(struct kobject *kobj, ...@@ -2851,7 +2852,7 @@ static ssize_t nr_overcommit_hugepages_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf) struct kobj_attribute *attr, char *buf)
{ {
struct hstate *h = kobj_to_hstate(kobj, NULL); struct hstate *h = kobj_to_hstate(kobj, NULL);
return sprintf(buf, "%lu\n", h->nr_overcommit_huge_pages); return sysfs_emit(buf, "%lu\n", h->nr_overcommit_huge_pages);
} }
static ssize_t nr_overcommit_hugepages_store(struct kobject *kobj, static ssize_t nr_overcommit_hugepages_store(struct kobject *kobj,
...@@ -2889,7 +2890,7 @@ static ssize_t free_hugepages_show(struct kobject *kobj, ...@@ -2889,7 +2890,7 @@ static ssize_t free_hugepages_show(struct kobject *kobj,
else else
free_huge_pages = h->free_huge_pages_node[nid]; free_huge_pages = h->free_huge_pages_node[nid];
return sprintf(buf, "%lu\n", free_huge_pages); return sysfs_emit(buf, "%lu\n", free_huge_pages);
} }
HSTATE_ATTR_RO(free_hugepages); HSTATE_ATTR_RO(free_hugepages);
...@@ -2897,7 +2898,7 @@ static ssize_t resv_hugepages_show(struct kobject *kobj, ...@@ -2897,7 +2898,7 @@ static ssize_t resv_hugepages_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf) struct kobj_attribute *attr, char *buf)
{ {
struct hstate *h = kobj_to_hstate(kobj, NULL); struct hstate *h = kobj_to_hstate(kobj, NULL);
return sprintf(buf, "%lu\n", h->resv_huge_pages); return sysfs_emit(buf, "%lu\n", h->resv_huge_pages);
} }
HSTATE_ATTR_RO(resv_hugepages); HSTATE_ATTR_RO(resv_hugepages);
...@@ -2914,7 +2915,7 @@ static ssize_t surplus_hugepages_show(struct kobject *kobj, ...@@ -2914,7 +2915,7 @@ static ssize_t surplus_hugepages_show(struct kobject *kobj,
else else
surplus_huge_pages = h->surplus_huge_pages_node[nid]; surplus_huge_pages = h->surplus_huge_pages_node[nid];
return sprintf(buf, "%lu\n", surplus_huge_pages); return sysfs_emit(buf, "%lu\n", surplus_huge_pages);
} }
HSTATE_ATTR_RO(surplus_hugepages); HSTATE_ATTR_RO(surplus_hugepages);
......
...@@ -126,7 +126,7 @@ static ssize_t scan_sleep_millisecs_show(struct kobject *kobj, ...@@ -126,7 +126,7 @@ static ssize_t scan_sleep_millisecs_show(struct kobject *kobj,
struct kobj_attribute *attr, struct kobj_attribute *attr,
char *buf) char *buf)
{ {
return sprintf(buf, "%u\n", khugepaged_scan_sleep_millisecs); return sysfs_emit(buf, "%u\n", khugepaged_scan_sleep_millisecs);
} }
static ssize_t scan_sleep_millisecs_store(struct kobject *kobj, static ssize_t scan_sleep_millisecs_store(struct kobject *kobj,
...@@ -154,7 +154,7 @@ static ssize_t alloc_sleep_millisecs_show(struct kobject *kobj, ...@@ -154,7 +154,7 @@ static ssize_t alloc_sleep_millisecs_show(struct kobject *kobj,
struct kobj_attribute *attr, struct kobj_attribute *attr,
char *buf) char *buf)
{ {
return sprintf(buf, "%u\n", khugepaged_alloc_sleep_millisecs); return sysfs_emit(buf, "%u\n", khugepaged_alloc_sleep_millisecs);
} }
static ssize_t alloc_sleep_millisecs_store(struct kobject *kobj, static ssize_t alloc_sleep_millisecs_store(struct kobject *kobj,
...@@ -182,7 +182,7 @@ static ssize_t pages_to_scan_show(struct kobject *kobj, ...@@ -182,7 +182,7 @@ static ssize_t pages_to_scan_show(struct kobject *kobj,
struct kobj_attribute *attr, struct kobj_attribute *attr,
char *buf) char *buf)
{ {
return sprintf(buf, "%u\n", khugepaged_pages_to_scan); return sysfs_emit(buf, "%u\n", khugepaged_pages_to_scan);
} }
static ssize_t pages_to_scan_store(struct kobject *kobj, static ssize_t pages_to_scan_store(struct kobject *kobj,
struct kobj_attribute *attr, struct kobj_attribute *attr,
...@@ -207,7 +207,7 @@ static ssize_t pages_collapsed_show(struct kobject *kobj, ...@@ -207,7 +207,7 @@ static ssize_t pages_collapsed_show(struct kobject *kobj,
struct kobj_attribute *attr, struct kobj_attribute *attr,
char *buf) char *buf)
{ {
return sprintf(buf, "%u\n", khugepaged_pages_collapsed); return sysfs_emit(buf, "%u\n", khugepaged_pages_collapsed);
} }
static struct kobj_attribute pages_collapsed_attr = static struct kobj_attribute pages_collapsed_attr =
__ATTR_RO(pages_collapsed); __ATTR_RO(pages_collapsed);
...@@ -216,7 +216,7 @@ static ssize_t full_scans_show(struct kobject *kobj, ...@@ -216,7 +216,7 @@ static ssize_t full_scans_show(struct kobject *kobj,
struct kobj_attribute *attr, struct kobj_attribute *attr,
char *buf) char *buf)
{ {
return sprintf(buf, "%u\n", khugepaged_full_scans); return sysfs_emit(buf, "%u\n", khugepaged_full_scans);
} }
static struct kobj_attribute full_scans_attr = static struct kobj_attribute full_scans_attr =
__ATTR_RO(full_scans); __ATTR_RO(full_scans);
...@@ -250,7 +250,7 @@ static ssize_t khugepaged_max_ptes_none_show(struct kobject *kobj, ...@@ -250,7 +250,7 @@ static ssize_t khugepaged_max_ptes_none_show(struct kobject *kobj,
struct kobj_attribute *attr, struct kobj_attribute *attr,
char *buf) char *buf)
{ {
return sprintf(buf, "%u\n", khugepaged_max_ptes_none); return sysfs_emit(buf, "%u\n", khugepaged_max_ptes_none);
} }
static ssize_t khugepaged_max_ptes_none_store(struct kobject *kobj, static ssize_t khugepaged_max_ptes_none_store(struct kobject *kobj,
struct kobj_attribute *attr, struct kobj_attribute *attr,
...@@ -275,7 +275,7 @@ static ssize_t khugepaged_max_ptes_swap_show(struct kobject *kobj, ...@@ -275,7 +275,7 @@ static ssize_t khugepaged_max_ptes_swap_show(struct kobject *kobj,
struct kobj_attribute *attr, struct kobj_attribute *attr,
char *buf) char *buf)
{ {
return sprintf(buf, "%u\n", khugepaged_max_ptes_swap); return sysfs_emit(buf, "%u\n", khugepaged_max_ptes_swap);
} }
static ssize_t khugepaged_max_ptes_swap_store(struct kobject *kobj, static ssize_t khugepaged_max_ptes_swap_store(struct kobject *kobj,
...@@ -302,7 +302,7 @@ static ssize_t khugepaged_max_ptes_shared_show(struct kobject *kobj, ...@@ -302,7 +302,7 @@ static ssize_t khugepaged_max_ptes_shared_show(struct kobject *kobj,
struct kobj_attribute *attr, struct kobj_attribute *attr,
char *buf) char *buf)
{ {
return sprintf(buf, "%u\n", khugepaged_max_ptes_shared); return sysfs_emit(buf, "%u\n", khugepaged_max_ptes_shared);
} }
static ssize_t khugepaged_max_ptes_shared_store(struct kobject *kobj, static ssize_t khugepaged_max_ptes_shared_store(struct kobject *kobj,
......
...@@ -2833,7 +2833,7 @@ static void wait_while_offlining(void) ...@@ -2833,7 +2833,7 @@ static void wait_while_offlining(void)
static ssize_t sleep_millisecs_show(struct kobject *kobj, static ssize_t sleep_millisecs_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf) struct kobj_attribute *attr, char *buf)
{ {
return sprintf(buf, "%u\n", ksm_thread_sleep_millisecs); return sysfs_emit(buf, "%u\n", ksm_thread_sleep_millisecs);
} }
static ssize_t sleep_millisecs_store(struct kobject *kobj, static ssize_t sleep_millisecs_store(struct kobject *kobj,
...@@ -2857,7 +2857,7 @@ KSM_ATTR(sleep_millisecs); ...@@ -2857,7 +2857,7 @@ KSM_ATTR(sleep_millisecs);
static ssize_t pages_to_scan_show(struct kobject *kobj, static ssize_t pages_to_scan_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf) struct kobj_attribute *attr, char *buf)
{ {
return sprintf(buf, "%u\n", ksm_thread_pages_to_scan); return sysfs_emit(buf, "%u\n", ksm_thread_pages_to_scan);
} }
static ssize_t pages_to_scan_store(struct kobject *kobj, static ssize_t pages_to_scan_store(struct kobject *kobj,
...@@ -2880,7 +2880,7 @@ KSM_ATTR(pages_to_scan); ...@@ -2880,7 +2880,7 @@ KSM_ATTR(pages_to_scan);
static ssize_t run_show(struct kobject *kobj, struct kobj_attribute *attr, static ssize_t run_show(struct kobject *kobj, struct kobj_attribute *attr,
char *buf) char *buf)
{ {
return sprintf(buf, "%lu\n", ksm_run); return sysfs_emit(buf, "%lu\n", ksm_run);
} }
static ssize_t run_store(struct kobject *kobj, struct kobj_attribute *attr, static ssize_t run_store(struct kobject *kobj, struct kobj_attribute *attr,
...@@ -2929,7 +2929,7 @@ KSM_ATTR(run); ...@@ -2929,7 +2929,7 @@ KSM_ATTR(run);
static ssize_t merge_across_nodes_show(struct kobject *kobj, static ssize_t merge_across_nodes_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf) struct kobj_attribute *attr, char *buf)
{ {
return sprintf(buf, "%u\n", ksm_merge_across_nodes); return sysfs_emit(buf, "%u\n", ksm_merge_across_nodes);
} }
static ssize_t merge_across_nodes_store(struct kobject *kobj, static ssize_t merge_across_nodes_store(struct kobject *kobj,
...@@ -2986,7 +2986,7 @@ KSM_ATTR(merge_across_nodes); ...@@ -2986,7 +2986,7 @@ KSM_ATTR(merge_across_nodes);
static ssize_t use_zero_pages_show(struct kobject *kobj, static ssize_t use_zero_pages_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf) struct kobj_attribute *attr, char *buf)
{ {
return sprintf(buf, "%u\n", ksm_use_zero_pages); return sysfs_emit(buf, "%u\n", ksm_use_zero_pages);
} }
static ssize_t use_zero_pages_store(struct kobject *kobj, static ssize_t use_zero_pages_store(struct kobject *kobj,
struct kobj_attribute *attr, struct kobj_attribute *attr,
...@@ -3008,7 +3008,7 @@ KSM_ATTR(use_zero_pages); ...@@ -3008,7 +3008,7 @@ KSM_ATTR(use_zero_pages);
static ssize_t max_page_sharing_show(struct kobject *kobj, static ssize_t max_page_sharing_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf) struct kobj_attribute *attr, char *buf)
{ {
return sprintf(buf, "%u\n", ksm_max_page_sharing); return sysfs_emit(buf, "%u\n", ksm_max_page_sharing);
} }
static ssize_t max_page_sharing_store(struct kobject *kobj, static ssize_t max_page_sharing_store(struct kobject *kobj,
...@@ -3049,21 +3049,21 @@ KSM_ATTR(max_page_sharing); ...@@ -3049,21 +3049,21 @@ KSM_ATTR(max_page_sharing);
static ssize_t pages_shared_show(struct kobject *kobj, static ssize_t pages_shared_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf) struct kobj_attribute *attr, char *buf)
{ {
return sprintf(buf, "%lu\n", ksm_pages_shared); return sysfs_emit(buf, "%lu\n", ksm_pages_shared);
} }
KSM_ATTR_RO(pages_shared); KSM_ATTR_RO(pages_shared);
static ssize_t pages_sharing_show(struct kobject *kobj, static ssize_t pages_sharing_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf) struct kobj_attribute *attr, char *buf)
{ {
return sprintf(buf, "%lu\n", ksm_pages_sharing); return sysfs_emit(buf, "%lu\n", ksm_pages_sharing);
} }
KSM_ATTR_RO(pages_sharing); KSM_ATTR_RO(pages_sharing);
static ssize_t pages_unshared_show(struct kobject *kobj, static ssize_t pages_unshared_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf) struct kobj_attribute *attr, char *buf)
{ {
return sprintf(buf, "%lu\n", ksm_pages_unshared); return sysfs_emit(buf, "%lu\n", ksm_pages_unshared);
} }
KSM_ATTR_RO(pages_unshared); KSM_ATTR_RO(pages_unshared);
...@@ -3080,21 +3080,21 @@ static ssize_t pages_volatile_show(struct kobject *kobj, ...@@ -3080,21 +3080,21 @@ static ssize_t pages_volatile_show(struct kobject *kobj,
*/ */
if (ksm_pages_volatile < 0) if (ksm_pages_volatile < 0)
ksm_pages_volatile = 0; ksm_pages_volatile = 0;
return sprintf(buf, "%ld\n", ksm_pages_volatile); return sysfs_emit(buf, "%ld\n", ksm_pages_volatile);
} }
KSM_ATTR_RO(pages_volatile); KSM_ATTR_RO(pages_volatile);
static ssize_t stable_node_dups_show(struct kobject *kobj, static ssize_t stable_node_dups_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf) struct kobj_attribute *attr, char *buf)
{ {
return sprintf(buf, "%lu\n", ksm_stable_node_dups); return sysfs_emit(buf, "%lu\n", ksm_stable_node_dups);
} }
KSM_ATTR_RO(stable_node_dups); KSM_ATTR_RO(stable_node_dups);
static ssize_t stable_node_chains_show(struct kobject *kobj, static ssize_t stable_node_chains_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf) struct kobj_attribute *attr, char *buf)
{ {
return sprintf(buf, "%lu\n", ksm_stable_node_chains); return sysfs_emit(buf, "%lu\n", ksm_stable_node_chains);
} }
KSM_ATTR_RO(stable_node_chains); KSM_ATTR_RO(stable_node_chains);
...@@ -3103,7 +3103,7 @@ stable_node_chains_prune_millisecs_show(struct kobject *kobj, ...@@ -3103,7 +3103,7 @@ stable_node_chains_prune_millisecs_show(struct kobject *kobj,
struct kobj_attribute *attr, struct kobj_attribute *attr,
char *buf) char *buf)
{ {
return sprintf(buf, "%u\n", ksm_stable_node_chains_prune_millisecs); return sysfs_emit(buf, "%u\n", ksm_stable_node_chains_prune_millisecs);
} }
static ssize_t static ssize_t
...@@ -3127,7 +3127,7 @@ KSM_ATTR(stable_node_chains_prune_millisecs); ...@@ -3127,7 +3127,7 @@ KSM_ATTR(stable_node_chains_prune_millisecs);
static ssize_t full_scans_show(struct kobject *kobj, static ssize_t full_scans_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf) struct kobj_attribute *attr, char *buf)
{ {
return sprintf(buf, "%lu\n", ksm_scan.seqnr); return sysfs_emit(buf, "%lu\n", ksm_scan.seqnr);
} }
KSM_ATTR_RO(full_scans); KSM_ATTR_RO(full_scans);
......
...@@ -902,7 +902,8 @@ struct page *swapin_readahead(swp_entry_t entry, gfp_t gfp_mask, ...@@ -902,7 +902,8 @@ struct page *swapin_readahead(swp_entry_t entry, gfp_t gfp_mask,
static ssize_t vma_ra_enabled_show(struct kobject *kobj, static ssize_t vma_ra_enabled_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf) struct kobj_attribute *attr, char *buf)
{ {
return sprintf(buf, "%s\n", enable_vma_readahead ? "true" : "false"); return sysfs_emit(buf, "%s\n",
enable_vma_readahead ? "true" : "false");
} }
static ssize_t vma_ra_enabled_store(struct kobject *kobj, static ssize_t vma_ra_enabled_store(struct kobject *kobj,
struct kobj_attribute *attr, struct kobj_attribute *attr,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment