mm: huge_memory: convert remaining use of sprintf to sysfs_emit and neatening
Convert the only use of sprintf with struct kobject * that the cocci script could not convert. Miscellanea: - Neaten the uses of a constant string with sysfs_emit to use a const char * to reduce overall object size Link: https://lkml.kernel.org/r/7df6be66bbd68e1a0bca9d35aca1341dbf94d2a7.1605376435.git.joe@perches.com Signed-off-by: Joe Perches <joe@perches.com> Cc: Christoph Lameter <cl@linux.com> Cc: David Rientjes <rientjes@google.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Hugh Dickins <hughd@google.com> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: Mike Kravetz <mike.kravetz@oracle.com> Cc: Pekka Enberg <penberg@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
ae7a927d27
commit
bfb0ffeb2a
@ -163,12 +163,17 @@ static struct shrinker huge_zero_page_shrinker = {
|
||||
static ssize_t enabled_show(struct kobject *kobj,
|
||||
struct kobj_attribute *attr, char *buf)
|
||||
{
|
||||
const char *output;
|
||||
|
||||
if (test_bit(TRANSPARENT_HUGEPAGE_FLAG, &transparent_hugepage_flags))
|
||||
return sysfs_emit(buf, "[always] madvise never\n");
|
||||
else if (test_bit(TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG, &transparent_hugepage_flags))
|
||||
return sysfs_emit(buf, "always [madvise] never\n");
|
||||
output = "[always] madvise never";
|
||||
else if (test_bit(TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG,
|
||||
&transparent_hugepage_flags))
|
||||
output = "always [madvise] never";
|
||||
else
|
||||
return sysfs_emit(buf, "always madvise [never]\n");
|
||||
output = "always madvise [never]";
|
||||
|
||||
return sysfs_emit(buf, "%s\n", output);
|
||||
}
|
||||
|
||||
static ssize_t enabled_store(struct kobject *kobj,
|
||||
@ -200,11 +205,11 @@ static struct kobj_attribute enabled_attr =
|
||||
__ATTR(enabled, 0644, enabled_show, enabled_store);
|
||||
|
||||
ssize_t single_hugepage_flag_show(struct kobject *kobj,
|
||||
struct kobj_attribute *attr, char *buf,
|
||||
enum transparent_hugepage_flag flag)
|
||||
struct kobj_attribute *attr, char *buf,
|
||||
enum transparent_hugepage_flag flag)
|
||||
{
|
||||
return sprintf(buf, "%d\n",
|
||||
!!test_bit(flag, &transparent_hugepage_flags));
|
||||
return sysfs_emit(buf, "%d\n",
|
||||
!!test_bit(flag, &transparent_hugepage_flags));
|
||||
}
|
||||
|
||||
ssize_t single_hugepage_flag_store(struct kobject *kobj,
|
||||
@ -232,19 +237,24 @@ ssize_t single_hugepage_flag_store(struct kobject *kobj,
|
||||
static ssize_t defrag_show(struct kobject *kobj,
|
||||
struct kobj_attribute *attr, char *buf)
|
||||
{
|
||||
if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG, &transparent_hugepage_flags))
|
||||
return sysfs_emit(buf,
|
||||
"[always] defer defer+madvise madvise never\n");
|
||||
if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG, &transparent_hugepage_flags))
|
||||
return sysfs_emit(buf,
|
||||
"always [defer] defer+madvise madvise never\n");
|
||||
if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_OR_MADV_FLAG, &transparent_hugepage_flags))
|
||||
return sysfs_emit(buf,
|
||||
"always defer [defer+madvise] madvise never\n");
|
||||
if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG, &transparent_hugepage_flags))
|
||||
return sysfs_emit(buf,
|
||||
"always defer defer+madvise [madvise] never\n");
|
||||
return sysfs_emit(buf, "always defer defer+madvise madvise [never]\n");
|
||||
const char *output;
|
||||
|
||||
if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG,
|
||||
&transparent_hugepage_flags))
|
||||
output = "[always] defer defer+madvise madvise never";
|
||||
else if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG,
|
||||
&transparent_hugepage_flags))
|
||||
output = "always [defer] defer+madvise madvise never";
|
||||
else if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_OR_MADV_FLAG,
|
||||
&transparent_hugepage_flags))
|
||||
output = "always defer [defer+madvise] madvise never";
|
||||
else if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG,
|
||||
&transparent_hugepage_flags))
|
||||
output = "always defer defer+madvise [madvise] never";
|
||||
else
|
||||
output = "always defer defer+madvise madvise [never]";
|
||||
|
||||
return sysfs_emit(buf, "%s\n", output);
|
||||
}
|
||||
|
||||
static ssize_t defrag_store(struct kobject *kobj,
|
||||
|
Loading…
Reference in New Issue
Block a user