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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAB3FC433F5 for ; Fri, 29 Apr 2022 09:05:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 32B2E6B0071; Fri, 29 Apr 2022 05:05:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2DB286B0073; Fri, 29 Apr 2022 05:05:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C9686B0074; Fri, 29 Apr 2022 05:05:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 084A66B0071 for ; Fri, 29 Apr 2022 05:05:19 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id C750061827 for ; Fri, 29 Apr 2022 09:05:18 +0000 (UTC) X-FDA: 79409332716.14.3BF08A1 Received: from outbound-smtp26.blacknight.com (outbound-smtp26.blacknight.com [81.17.249.194]) by imf09.hostedemail.com (Postfix) with ESMTP id D169A14004F for ; Fri, 29 Apr 2022 09:05:13 +0000 (UTC) Received: from mail.blacknight.com (pemlinmail05.blacknight.ie [81.17.254.26]) by outbound-smtp26.blacknight.com (Postfix) with ESMTPS id 67490CAEF4 for ; Fri, 29 Apr 2022 10:05:16 +0100 (IST) Received: (qmail 24973 invoked from network); 29 Apr 2022 09:05:16 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.198.246]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 29 Apr 2022 09:05:16 -0000 Date: Fri, 29 Apr 2022 10:05:11 +0100 From: Mel Gorman To: Minchan Kim Cc: Nicolas Saenz Julienne , Marcelo Tosatti , Vlastimil Babka , Michal Hocko , LKML , Linux-MM Subject: Re: [PATCH 5/6] mm/page_alloc: Protect PCP lists with a spinlock Message-ID: <20220429090511.GA3441@techsingularity.net> References: <20220420095906.27349-1-mgorman@techsingularity.net> <20220420095906.27349-6-mgorman@techsingularity.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: D169A14004F X-Stat-Signature: xstisbkkpi9tu1srebmuxtjo81o83st1 Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf09.hostedemail.com: domain of mgorman@techsingularity.net designates 81.17.249.194 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net X-HE-Tag: 1651223113-491828 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 Tue, Apr 26, 2022 at 12:24:56PM -0700, Minchan Kim wrote: > > @@ -3450,10 +3496,19 @@ void free_unref_page(struct page *page, unsigned int order) > > void free_unref_page_list(struct list_head *list) > > { > > struct page *page, *next; > > + struct per_cpu_pages *pcp; > > + struct zone *locked_zone; > > unsigned long flags; > > int batch_count = 0; > > int migratetype; > > > > + /* > > + * An empty list is possible. Check early so that the later > > + * lru_to_page() does not potentially read garbage. > > + */ > > + if (list_empty(list)) > > + return; > > + > > /* Prepare pages for freeing */ > > list_for_each_entry_safe(page, next, list, lru) { > > unsigned long pfn = page_to_pfn(page); > > @@ -3474,8 +3529,26 @@ void free_unref_page_list(struct list_head *list) > > } > > } > > > > + VM_BUG_ON(in_hardirq()); > > You need to check the list_empty here again and bail out if it is. > You're right, every page could have failed to prepare or was isolated. -- Mel Gorman SUSE Labs