+ mm-and-drivers-core-convert-hugetlb_report_node_meminfo-to-sysfs_emit.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: mm: and drivers core: convert hugetlb_report_node_meminfo to sysfs_emit
has been added to the -mm tree.  Its filename is
     mm-and-drivers-core-convert-hugetlb_report_node_meminfo-to-sysfs_emit.patch

This patch should soon appear at
    https://ozlabs.org/~akpm/mmots/broken-out/mm-and-drivers-core-convert-hugetlb_report_node_meminfo-to-sysfs_emit.patch
and later at
    https://ozlabs.org/~akpm/mmotm/broken-out/mm-and-drivers-core-convert-hugetlb_report_node_meminfo-to-sysfs_emit.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Joe Perches <joe@xxxxxxxxxxx>
Subject: mm: and drivers core: convert hugetlb_report_node_meminfo to sysfs_emit

Convert the unbound sprintf in hugetlb_report_node_meminfo to use
sysfs_emit_at so that no possible overrun of a PAGE_SIZE buf can occur.

Link: https://lkml.kernel.org/r/894b351b82da6013cde7f36ff4b5493cd0ec30d0.1600285923.git.joe@xxxxxxxxxxx
Signed-off-by: Joe Perches <joe@xxxxxxxxxxx>
Acked-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Cc: "Rafael J.Wysocki" <rafael@xxxxxxxxxx>
Cc: Denis Efremov <efremov@xxxxxxxxx>
Cc: Julia Lawall <julia.lawall@xxxxxxxx>
Cc: Alex Dewar <alex.dewar90@xxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 drivers/base/node.c     |    2 +-
 include/linux/hugetlb.h |    4 ++--
 mm/hugetlb.c            |   18 ++++++++++--------
 3 files changed, 13 insertions(+), 11 deletions(-)

--- a/drivers/base/node.c~mm-and-drivers-core-convert-hugetlb_report_node_meminfo-to-sysfs_emit
+++ a/drivers/base/node.c
@@ -467,7 +467,7 @@ static ssize_t node_read_meminfo(struct
 				       HPAGE_PMD_NR)
 #endif
 		       );
-	n += hugetlb_report_node_meminfo(nid, buf + n);
+	n += hugetlb_report_node_meminfo(buf, n, nid);
 	return n;
 }
 
--- a/include/linux/hugetlb.h~mm-and-drivers-core-convert-hugetlb_report_node_meminfo-to-sysfs_emit
+++ a/include/linux/hugetlb.h
@@ -129,7 +129,7 @@ void __unmap_hugepage_range(struct mmu_g
 				unsigned long start, unsigned long end,
 				struct page *ref_page);
 void hugetlb_report_meminfo(struct seq_file *);
-int hugetlb_report_node_meminfo(int, char *);
+int hugetlb_report_node_meminfo(char *buf, int len, int nid);
 void hugetlb_show_meminfo(void);
 unsigned long hugetlb_total_pages(void);
 vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
@@ -245,7 +245,7 @@ static inline void hugetlb_report_meminf
 {
 }
 
-static inline int hugetlb_report_node_meminfo(int nid, char *buf)
+static inline int hugetlb_report_node_meminfo(char *buf, int len, int nid)
 {
 	return 0;
 }
--- a/mm/hugetlb.c~mm-and-drivers-core-convert-hugetlb_report_node_meminfo-to-sysfs_emit
+++ a/mm/hugetlb.c
@@ -3582,18 +3582,20 @@ void hugetlb_report_meminfo(struct seq_f
 	seq_printf(m, "Hugetlb:        %8lu kB\n", total / 1024);
 }
 
-int hugetlb_report_node_meminfo(int nid, char *buf)
+int hugetlb_report_node_meminfo(char *buf, int len, int nid)
 {
 	struct hstate *h = &default_hstate;
+
 	if (!hugepages_supported())
 		return 0;
-	return sprintf(buf,
-		"Node %d HugePages_Total: %5u\n"
-		"Node %d HugePages_Free:  %5u\n"
-		"Node %d HugePages_Surp:  %5u\n",
-		nid, h->nr_huge_pages_node[nid],
-		nid, h->free_huge_pages_node[nid],
-		nid, h->surplus_huge_pages_node[nid]);
+
+	return sysfs_emit_at(buf, len,
+			     "Node %d HugePages_Total: %5u\n"
+			     "Node %d HugePages_Free:  %5u\n"
+			     "Node %d HugePages_Surp:  %5u\n",
+			     nid, h->nr_huge_pages_node[nid],
+			     nid, h->free_huge_pages_node[nid],
+			     nid, h->surplus_huge_pages_node[nid]);
 }
 
 void hugetlb_show_meminfo(void)
_

Patches currently in -mm which might be from joe@xxxxxxxxxxx are

mm-and-drivers-core-convert-hugetlb_report_node_meminfo-to-sysfs_emit.patch
checkpatch-test-git_dir-changes.patch
get_maintainer-add-test-for-file-in-vcs.patch
get_maintainer-exclude-maintainers-files-from-git-fallback.patch
checkpatch-move-repeated-word-test.patch
checkpatch-add-test-for-comma-use-that-should-be-semicolon.patch
checkpatch-warn-on-self-assignments.patch
checkpatch-allow-not-using-f-with-files-that-are-in-git.patch




[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux