Skip to contentSkip to conversation

mm: Mark undo_dev_pagemap as __maybe_unused

PATCH In review Guenter Roeck 2 participants 3 messages Jul 2, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: Mark undo_dev_pagemap as __maybe_unused

Several mips builds generate the following build warning.

mm/gup.c:1788:13: warning: 'undo_dev_pagemap' defined but not used

The function is declared unconditionally but only called from behind various ifdefs. Mark it __maybe_unused.

---
 mm/gup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
mm/gup.c +2 -1
index 7dde2e3a1963..95a373bd8f21 100644
@@ -1785,7 +1785,8 @@ static inline pte_t gup_get_pte(pte_t *ptep)
 }
 #endif /* CONFIG_GUP_GET_PTE_LOW_HIGH */
 
-static void undo_dev_pagemap(int *nr, int nr_start, struct page **pages)
+static void __maybe_unused undo_dev_pagemap(int *nr, int nr_start,
+					    struct page **pages)
 {
 	while ((*nr) - nr_start) {
 		struct page *page = pages[--(*nr)];
Signature · 1 line
2.7.4
maintainer
#1 lore raw
Quoted 12 lines · On Tue, 2 Jul 2019 06:02:03 -0700 Guenter Roeck <[email protected]> wrote:

Several mips builds generate the following build warning.

mm/gup.c:1788:13: warning: 'undo_dev_pagemap' defined but not used

The function is declared unconditionally but only called from behind various ifdefs. Mark it __maybe_unused.

...

mm/gup.c static inline pte_t gup_get_pte(pte_t *ptep) · line 1792

Quoted 9 lines
mm/gup.c +2 -1
@@ -1785,7 +1785,8 @@ static inline pte_t gup_get_pte(pte_t *ptep)
 }
 #endif /* CONFIG_GUP_GET_PTE_LOW_HIGH */
 
-static void undo_dev_pagemap(int *nr, int nr_start, struct page **pages)
+static void __maybe_unused undo_dev_pagemap(int *nr, int nr_start,
+					    struct page **pages)
 {
 	while ((*nr) - nr_start) {
 		struct page *page = pages[--(*nr)];

It's not our preferred way of doing it but yes, it would be a bit of a mess and a bit of a maintenance burden to get the ifdefs correct.

And really, __maybe_unused isn't a bad way at all - it ensures that the function always gets build-tested and the compiler will remove it so we don't have to play the chase-the-ifdefs game.

#2 lore raw
Quoted 17 lines · Andrew Morton
Quoted 15 lines · On Tue, 2 Jul 2019 06:02:03 -0700 Guenter Roeck <[email protected]> wrote:

Several mips builds generate the following build warning.

mm/gup.c:1788:13: warning: 'undo_dev_pagemap' defined but not used

The function is declared unconditionally but only called from behind various ifdefs. Mark it __maybe_unused.

...

mm/gup.c +0 -0
@@ -1785,7 +1785,8 @@ static inline pte_t gup_get_pte(pte_t *ptep)
  }
  #endif /* CONFIG_GUP_GET_PTE_LOW_HIGH */
 
Quoted 10 lines

mm/gup.c static inline pte_t gup_get_pte(pte_t *ptep) · line 1792

Quoted 6 lines
mm/gup.c +2 -1
-static void undo_dev_pagemap(int *nr, int nr_start, struct page **pages)
+static void __maybe_unused undo_dev_pagemap(int *nr, int nr_start,
+					    struct page **pages)
  {
  	while ((*nr) - nr_start) {
  		struct page *page = pages[--(*nr)];

It's not our preferred way of doing it but yes, it would be a bit of a mess and a bit of a maintenance burden to get the ifdefs correct.

That is why I did it here. I understand that some maintainers don't like it, and I noticed that it wasn't used elsewhere in the file, but it seemed to be to most straightforward solution.

Quoted 4 lines

And really, __maybe_unused isn't a bad way at all - it ensures that the function always gets build-tested and the compiler will remove it so we don't have to play the chase-the-ifdefs game.

Yes, it does have its advantages. I like it myself, but usually I would not impose my opinion on others. In this case, anything else would have been quite awkward and be prone to never-ending adjustments.

Thanks,
Guenter