All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -mm] mm, swap: Fix bad swap file entry warning
@ 2019-05-31  2:41 Huang, Ying
  2019-05-31  6:10 ` Michal Hocko
  2019-05-31 16:59 ` Mike Kravetz
  0 siblings, 2 replies; 11+ messages in thread
From: Huang, Ying @ 2019-05-31  2:41 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, linux-kernel, Huang Ying, Mike Kravetz, Andrea Parri,
	Paul E . McKenney, Michal Hocko, Minchan Kim, Hugh Dickins

From: Huang Ying <ying.huang@intel.com>

Mike reported the following warning messages

  get_swap_device: Bad swap file entry 1400000000000001

This is produced by

- total_swapcache_pages()
  - get_swap_device()

Where get_swap_device() is used to check whether the swap device is
valid and prevent it from being swapoff if so.  But get_swap_device()
may produce warning message as above for some invalid swap devices.
This is fixed via calling swp_swap_info() before get_swap_device() to
filter out the swap devices that may cause warning messages.

Fixes: 6a946753dbe6 ("mm/swap_state.c: simplify total_swapcache_pages() with get_swap_device()")
Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Andrea Parri <andrea.parri@amarulasolutions.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Hugh Dickins <hughd@google.com>
---
 mm/swap_state.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/mm/swap_state.c b/mm/swap_state.c
index b84c58b572ca..62da25b7f2ed 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -76,8 +76,13 @@ unsigned long total_swapcache_pages(void)
 	struct swap_info_struct *si;
 
 	for (i = 0; i < MAX_SWAPFILES; i++) {
+		swp_entry_t entry = swp_entry(i, 1);
+
+		/* Avoid get_swap_device() to warn for bad swap entry */
+		if (!swp_swap_info(entry))
+			continue;
 		/* Prevent swapoff to free swapper_spaces */
-		si = get_swap_device(swp_entry(i, 1));
+		si = get_swap_device(entry);
 		if (!si)
 			continue;
 		nr = nr_swapper_spaces[i];
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread
* Re: [PATCH -mm] mm, swap: Fix bad swap file entry warning
@ 2019-06-01  4:25 Yuri Norov
  0 siblings, 0 replies; 11+ messages in thread
From: Yuri Norov @ 2019-06-01  4:25 UTC (permalink / raw)
  To: Qian Cai, Dexuan-Linux Cui, Mike Kravetz
  Cc: Huang, Ying, Andrew Morton, linux-mm, Linux Kernel Mailing List,
	Andrea Parri, Paul E . McKenney, Michal Hocko, Minchan Kim,
	Hugh Dickins, Dexuan Cui, v-lide, Yury Norov

(Resend as LKML didn't take outlook settings.)

> On Fri, 2019-05-31 at 11:27 -0700, Dexuan-Linux Cui wrote:
> > Hi,
> > Did you know about the panic reported here:
> >  https://marc.info/?t=155930773000003&r=1&w=2
> > 
> > "Kernel panic - not syncing: stack-protector: Kernel stack is
> > corrupted in: write_irq_affinity.isra> "
> > 
> > This panic is reported on PowerPC and x86.
> > 
> > In the case of x86, we see a lot of "get_swap_device: Bad swap file entry"
> > errors before the panic:
> > 
> > ...
> > [   24.404693] get_swap_device: Bad swap file entry 5800000000000001
> > [   24.408702] get_swap_device: Bad swap file entry 5c00000000000001
> > [   24.412510] get_swap_device: Bad swap file entry 6000000000000001
> > [   24.416519] get_swap_device: Bad swap file entry 6400000000000001
> > [   24.420217] get_swap_device: Bad swap file entry 6800000000000001
> > [   24.423921] get_swap_device: Bad swap file entry 6c00000000000001

[..]

I don't have a panic, but I observe many lines like this.

> Looks familiar,
>
> https://lore.kernel.org/lkml/1559242868.6132.35.camel@lca.pw/
>
> I suppose Andrew might be better of reverting the whole series first before Yury
> came up with a right fix, so that other people who is testing linux-next don't
> need to waste time for the same problem.

I didn't observe any problems with this series on top of 5.1, and there's a fix for swap\
that eliminates the problem on top of current next for me:
https://lkml.org/lkml/2019/5/30/1630

Could you please test my series with the patch above?

Thanks,
Yury

     

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-06-01  4:25 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-31  2:41 [PATCH -mm] mm, swap: Fix bad swap file entry warning Huang, Ying
2019-05-31  6:10 ` Michal Hocko
2019-06-01  0:14   ` Huang, Ying
2019-06-01  0:14     ` Huang, Ying
2019-05-31 16:59 ` Mike Kravetz
2019-05-31 18:27   ` Dexuan-Linux Cui
2019-05-31 18:27     ` Dexuan-Linux Cui
2019-05-31 19:16     ` Qian Cai
2019-05-31 19:16       ` Qian Cai
2019-05-31 22:36       ` [EXT] " Yuri Norov
2019-06-01  4:25 Yuri Norov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.