linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Huang\, Ying" <ying.huang@intel.com>
To: Michal Hocko <mhocko@suse.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	 linux-mm@kvack.org,  linux-kernel@vger.kernel.org,
	 Minchan Kim <minchan@kernel.org>,
	 Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	 Johannes Weiner <hannes@cmpxchg.org>,
	 Vlastimil Babka <vbabka@suse.cz>,
	 Mel Gorman <mgorman@techsingularity.net>,
	 Dan Williams <dan.j.williams@intel.com>,
	 Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH] swap: Check nrexceptional of swap cache before being freed
Date: Wed, 20 Jan 2021 15:54:04 +0800	[thread overview]
Message-ID: <87v9bst55v.fsf@yhuang-dev.intel.com> (raw)
In-Reply-To: <20210120074652.GA9371@dhcp22.suse.cz> (Michal Hocko's message of "Wed, 20 Jan 2021 08:46:52 +0100")

Michal Hocko <mhocko@suse.com> writes:

> On Wed 20-01-21 15:27:11, Huang Ying wrote:
>> To catch the error in updating the swap cache shadow entries or their count.
>
> What is the error?

There's no error in the current code.  But we will change the related
code in the future.  So this checking will help us to prevent error in
the future.  I will change the patch description to make it more clear.

> Can it happens in the real life? Why do we need this
> patch? Is crashing the kernel the right way to handle the situation?

Emm... The mistake to update swap shadow entries will hurt performance,
but will not trigger functionality bug.  So it may be better to use
VM_WARN_ON_ONCE().

Best Regards,
Huang, Ying


>> Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
>> Cc: Minchan Kim <minchan@kernel.org>
>> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>,
>> Cc: Johannes Weiner <hannes@cmpxchg.org>,
>> Cc: Vlastimil Babka <vbabka@suse.cz>, Hugh Dickins <hughd@google.com>,
>> Cc: Mel Gorman <mgorman@techsingularity.net>,
>> Cc: Michal Hocko <mhocko@kernel.org>,
>> Cc: Dan Williams <dan.j.williams@intel.com>,
>> Cc: Christoph Hellwig <hch@lst.de>, Ilya Dryomov <idryomov@gmail.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 d0d417efeecc..240a4f97594a 100644
>> --- a/mm/swap_state.c
>> +++ b/mm/swap_state.c
>> @@ -703,7 +703,12 @@ int init_swap_address_space(unsigned int type, unsigned long nr_pages)
>>  
>>  void exit_swap_address_space(unsigned int type)
>>  {
>> -	kvfree(swapper_spaces[type]);
>> +	int i;
>> +	struct address_space *spaces = swapper_spaces[type];
>> +
>> +	for (i = 0; i < nr_swapper_spaces[type]; i++)
>> +		VM_BUG_ON(spaces[i].nrexceptional);
>> +	kvfree(spaces);
>>  	nr_swapper_spaces[type] = 0;
>>  	swapper_spaces[type] = NULL;
>>  }
>> -- 
>> 2.29.2


  reply	other threads:[~2021-01-20  7:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-20  7:27 [PATCH] swap: Check nrexceptional of swap cache before being freed Huang Ying
2021-01-20  7:46 ` Michal Hocko
2021-01-20  7:54   ` Huang, Ying [this message]
2021-01-20  7:59     ` Michal Hocko
2021-01-21 18:44 ` Matthew Wilcox
2021-01-22  0:02   ` Huang, Ying

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v9bst55v.fsf@yhuang-dev.intel.com \
    --to=ying.huang@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=dan.j.williams@intel.com \
    --cc=hannes@cmpxchg.org \
    --cc=hch@lst.de \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@suse.com \
    --cc=minchan@kernel.org \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).