From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FBCFC433E6 for ; Wed, 20 Jan 2021 07:46:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B45B223131 for ; Wed, 20 Jan 2021 07:46:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B45B223131 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EB5276B0007; Wed, 20 Jan 2021 02:46:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E650E6B0008; Wed, 20 Jan 2021 02:46:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D7C136B000A; Wed, 20 Jan 2021 02:46:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0199.hostedemail.com [216.40.44.199]) by kanga.kvack.org (Postfix) with ESMTP id C2A816B0007 for ; Wed, 20 Jan 2021 02:46:56 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 83582364A for ; Wed, 20 Jan 2021 07:46:56 +0000 (UTC) X-FDA: 77725372032.17.run54_5c10e7b27558 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 5D7EC180D0181 for ; Wed, 20 Jan 2021 07:46:56 +0000 (UTC) X-HE-Tag: run54_5c10e7b27558 X-Filterd-Recvd-Size: 3196 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Wed, 20 Jan 2021 07:46:55 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1611128814; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ueiYHJsmAMlmc2zh0uWWVeND9IJsp4Ikx2aN0R8JzWU=; b=NuEMbEzrVLOY7iFauN0i3IO+XiSQoKmLRgTV4/nlOhqMGSpYxzoa/uqAUKdU2rZcWE/8Th kepjL7JgQneqEisWC3a+ZTlc/PoLnRY1HZJeqN+e1boS6z/8V/F89I09q/oe+rUY+Zwfzl ZcpQ2gzDJr4fnumXgoj+ARJajabcLpY= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 8E3CCAAAE; Wed, 20 Jan 2021 07:46:54 +0000 (UTC) Date: Wed, 20 Jan 2021 08:46:52 +0100 From: Michal Hocko To: Huang Ying Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Minchan Kim , Joonsoo Kim , Johannes Weiner , Vlastimil Babka , Mel Gorman , Dan Williams , Christoph Hellwig Subject: Re: [PATCH] swap: Check nrexceptional of swap cache before being freed Message-ID: <20210120074652.GA9371@dhcp22.suse.cz> References: <20210120072711.209099-1-ying.huang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210120072711.209099-1-ying.huang@intel.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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? Can it happens in the real life? Why do we need this patch? Is crashing the kernel the right way to handle the situation? > Signed-off-by: "Huang, Ying" > Cc: Minchan Kim > Cc: Joonsoo Kim , > Cc: Johannes Weiner , > Cc: Vlastimil Babka , Hugh Dickins , > Cc: Mel Gorman , > Cc: Michal Hocko , > Cc: Dan Williams , > Cc: Christoph Hellwig , Ilya Dryomov , > --- > 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 -- Michal Hocko SUSE Labs