Skip to contentSkip to conversation

Remove warnings from today's mmotm

PATCH In review Matthew Wilcox (Oracle) 2 participants 7 messages Jun 15, 2021

Subsystems (5)
lore
Share & tools
lore

Matthew Wilcox (Oracle)

author maintainer
#0 lore raw

cover Remove warnings from today's mmotm

These warnings all show up with W=1. There's one more warning which I'm not really sure how to fix.

Matthew Wilcox (Oracle) (5):
mm writeback,cgroup: Fix documentation
Fix hugetlb_basepage_index missing prototype warning mm/thp: Fix strncpy warning mm/sparse-vmemmap: Fix documentation warning
mm: Fix alloc_vmemmap_page_list documentation warning

 include/linux/pagemap.h | 6 +++---
 mm/backing-dev.c        | 7 ++-----
 mm/huge_memory.c        | 2 +-
 mm/sparse-vmemmap.c     | 4 ++--
 4 files changed, 8 insertions(+), 11 deletions(-)
Signature · 1 line
2.30.2
author maintainer
#1 lore raw

PATCH 1/5 mm writeback,cgroup: Fix documentation

This is a static function, so it doesn't need kernel-doc. Also remove the inaccurate comment about the locking.

---
 mm/backing-dev.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
mm/backing-dev.c +2 -5
index 52eaeee40da3..271f2ca862c8 100644
@@ -645,15 +645,12 @@ static void cgwb_bdi_unregister(struct backing_dev_info *bdi)
 	mutex_unlock(&bdi->cgwb_release_mutex);
 }
 
-/**
- * cleanup_offline_cgwbs - try to release dying cgwbs
+/*
+ * cleanup_offline_cgwbs_workfn - try to release dying cgwbs
  *
  * Try to release dying cgwbs by switching attached inodes to the nearest
  * living ancestor's writeback. Processed wbs are placed at the end
  * of the list to guarantee the forward progress.
- *
- * Should be called with the acquired cgwb_lock lock, which might
- * be released and re-acquired in the process.
  */
 static void cleanup_offline_cgwbs_workfn(struct work_struct *work)
 {
Signature · 1 line
2.30.2
author maintainer
#2 lore raw

PATCH 2/5 Fix hugetlb_basepage_index missing prototype warning

In reply to Matthew Wilcox (Oracle)

-Wmissing-prototypes requires that the prototype actually be in scope, not just previously seen. Move it outside page_to_pgoff().

---
 include/linux/pagemap.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/pagemap.h +3 -3
index 5f0582de24e7..c4b1514818ff 100644
@@ -585,16 +585,16 @@ static inline pgoff_t page_to_index(struct page *page)
 	return pgoff;
 }
 
+extern pgoff_t hugetlb_basepage_index(struct page *page);
+
 /*
  * Get the offset in PAGE_SIZE (even for hugetlb pages).
  * (TODO: hugetlb pages should have ->index in PAGE_SIZE)
  */
 static inline pgoff_t page_to_pgoff(struct page *page)
 {
-	if (unlikely(PageHuge(page))) {
-		extern pgoff_t hugetlb_basepage_index(struct page *page);
+	if (unlikely(PageHuge(page)))
 		return hugetlb_basepage_index(page);
-	}
 	return page_to_index(page);
 }
 
Signature · 1 line
2.30.2
Acked-by on v1 2/5
#3 lore raw

Re: [PATCH 2/5] Fix hugetlb_basepage_index missing prototype warning

Quoted 4 lines · Matthew Wilcox (Oracle)

-Wmissing-prototypes requires that the prototype actually be in scope, not just previously seen. Move it outside page_to_pgoff().

Thanks Matthew:

but Andrew please just add as a -fix.patch to mm-futex-fix-shared-futex-pgoff-on-shmem-huge-page.patch and merge them in due course - thank you.

Quoted 30 lines
---
 include/linux/pagemap.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/pagemap.h +3 -3
index 5f0582de24e7..c4b1514818ff 100644
@@ -585,16 +585,16 @@ static inline pgoff_t page_to_index(struct page *page)
 	return pgoff;
 }
 
+extern pgoff_t hugetlb_basepage_index(struct page *page);
+
 /*
  * Get the offset in PAGE_SIZE (even for hugetlb pages).
  * (TODO: hugetlb pages should have ->index in PAGE_SIZE)
  */
 static inline pgoff_t page_to_pgoff(struct page *page)
 {
-	if (unlikely(PageHuge(page))) {
-		extern pgoff_t hugetlb_basepage_index(struct page *page);
+	if (unlikely(PageHuge(page)))
 		return hugetlb_basepage_index(page);
-	}
 	return page_to_index(page);
 }
 
Signature · 1 line
2.30.2
author maintainer
#4 lore raw

PATCH 3/5 mm/thp: Fix strncpy warning

In reply to Matthew Wilcox (Oracle)

Using MAX_INPUT_BUF_SZ as the maximum length of the string makes fortify complain as it thinks the string might be longer than the buffer, and if it is, we will end up with a "string" that is missing a NUL terminator. It's trivial to show that 'tok' points to a NUL-terminated string which is less than MAX_INPUT_BUF_SZ in length, so we may as well just use strcpy() and avoid the warning.

---
 mm/huge_memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/huge_memory.c +1 -1
index 503c8e1aecc6..d513b0cd1161 100644
@@ -3101,7 +3101,7 @@ static ssize_t split_huge_pages_write(struct file *file, const char __user *buf,
 
 		tok = strsep(&buf, ",");
 		if (tok) {
-			strncpy(file_path, tok, MAX_INPUT_BUF_SZ);
+			strcpy(file_path, tok);
 		} else {
 			ret = -EINVAL;
 			goto out;
Signature · 1 line
2.30.2
author maintainer
#5 lore raw

PATCH 4/5 mm/sparse-vmemmap: Fix documentation warning

In reply to Matthew Wilcox (Oracle)

vmemmap_remap_walk is a struct, not a function, and needs to be marked accordingly.

---
 mm/sparse-vmemmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/sparse-vmemmap.c +1 -1
index 693de0aec7a8..66740a79fe4e 100644
@@ -35,7 +35,7 @@
 #include <asm/tlbflush.h>
 
 /**
- * vmemmap_remap_walk - walk vmemmap page table
+ * struct vmemmap_remap_walk - walk vmemmap page table
  *
  * @remap_pte:		called for each lowest-level entry (PTE).
  * @reuse_page:		the page which is reused for the tail vmemmap pages.
Signature · 1 line
2.30.2
author maintainer
#6 lore raw

PATCH 5/5 mm: Fix alloc_vmemmap_page_list documentation warning

In reply to Matthew Wilcox (Oracle)

This simple typo generates two warnings from kernel-doc.

---
 mm/sparse-vmemmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/sparse-vmemmap.c +1 -1
index 66740a79fe4e..a3aa275e2668 100644
@@ -272,7 +272,7 @@ static int alloc_vmemmap_page_list(unsigned long start, unsigned long end,
  * @end:	end address of the vmemmap virtual address range that we want to
  *		remap.
  * @reuse:	reuse address.
- * @gpf_mask:	GFP flag for allocating vmemmap pages.
+ * @gfp_mask:	GFP flag for allocating vmemmap pages.
  */
 int vmemmap_remap_alloc(unsigned long start, unsigned long end,
 			unsigned long reuse, gfp_t gfp_mask)
Signature · 1 line
2.30.2