Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp431449pxt; Thu, 12 Aug 2021 01:41:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFI520E7N6+iwB2j0aGrkpZ9PJtneiO8yYTVtpF5j4F9/yPz35ilkieIT6reZCPes6FzvR X-Received: by 2002:a50:ec0a:: with SMTP id g10mr4132702edr.125.1628757688713; Thu, 12 Aug 2021 01:41:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628757688; cv=none; d=google.com; s=arc-20160816; b=KaOF6FRi6gsP9cQb/ScBiiH4YYiIOVglz9e+Sxd0SjeUAo246SZcCEXFpD844MsthI bJKO7/3x60I6VtD2q8N8frMNEuTzDHhu4mHNZ8Hj7wa2BTTXHEIJzmXTg6akXkHQRKGG ahq8qsMuv/1ZSG1X6LqvxSu5QDVcoBt2oY1N1nzk1nhSE3vI8MkLjZDHkr5hqh8VPLH2 g2cpQNvZOylM2li0fIePuyYVsZtdXQHSZyBc0syGSpQu2gF4RUyKkxdhHFFxpCBxF579 wWvPwOjhvu9weCda3EvfVLGJODy4ZhOGSE1U7lmRmQnDT/iVcrn6h9iTwsPsIZWG2yCs /c1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:dkim-signature; bh=XhUBbQGoB6p8bEf2qX/5QpELujZexaxBGuC5JTzfSDM=; b=Zyh3THqJS5Xtln/ZhRQXF+sO4nRH1iA0t2zAYih9KV7cg0E5QT8PmvirNPh2meUOd7 ZR3HjXTiCZKqcW6s+A6mVNCJnauoH/W7tMi65YIPxJfIC4oVMCZNuyYwIG+at7r+AEFO U89gZIuT4OFYLx9xv9/otB9giw4HE4VIcN4S1A0446zm9SsgTRK8e5grsHa/Wj2t8OzE QE98PYYZtm2RR8xNf5h8VTVTegl63zQp7L0m7aOyFzo9oRLlvqamaQ49ptFK75UnNgr4 HGUfBKUCp+tnrwaiQrW2LsAxPDsG/IaHZf+n6EKZJAaR2wf8qP7vj5ar+5g7QPN5E6m0 OLcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=MbGR9PmP; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=bIM75yup; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a5si215649eds.231.2021.08.12.01.41.04; Thu, 12 Aug 2021 01:41:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=MbGR9PmP; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=bIM75yup; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234521AbhHLIRi (ORCPT + 99 others); Thu, 12 Aug 2021 04:17:38 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:45446 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234093AbhHLIRh (ORCPT ); Thu, 12 Aug 2021 04:17:37 -0400 Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 0B78A221F8; Thu, 12 Aug 2021 08:17:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1628756229; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XhUBbQGoB6p8bEf2qX/5QpELujZexaxBGuC5JTzfSDM=; b=MbGR9PmPkpqmBlcQWHETfLfu3OX7aehs5QhGzYXN+gttgruCc3jw+hRzGD/GApL6AAHS6j 9emlMqHGYehsZNituVpp24WTEIRThfzcdblZeR3FLSD+msUWjXQIa5RwoNVf6dD7v9+CVn OyXzKJ64BAnUupnp6v4ax7i0JCovr9M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1628756229; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XhUBbQGoB6p8bEf2qX/5QpELujZexaxBGuC5JTzfSDM=; b=bIM75yupX0YZsrTG7vsDfKYUhff83BKuiRr7b3LtlCN6LFBrNa7pyBH1yfqT0yJh9KutPI lPYtGqDWcmVCngCg== Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id D09CB13846; Thu, 12 Aug 2021 08:17:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id p2wpMgTZFGHQCAAAGKfGzw (envelope-from ); Thu, 12 Aug 2021 08:17:08 +0000 Subject: Re: [PATCH] mm/page_alloc: don't corrupt pcppage_migratetype To: Doug Berger , Andrew Morton Cc: Mel Gorman , "Peter Zijlstra (Intel)" , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20210811182917.2607994-1-opendmb@gmail.com> From: Vlastimil Babka Message-ID: Date: Thu, 12 Aug 2021 10:17:08 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210811182917.2607994-1-opendmb@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/11/21 8:29 PM, Doug Berger wrote: > When placing pages on a pcp list, migratetype values over > MIGRATE_PCPTYPES get added to the MIGRATE_MOVABLE pcp list. > > However, the actual migratetype is preserved in the page and > should not be changed to MIGRATE_MOVABLE or the page may end > up on the wrong free_list. Nice, how did you find out? Were there any user-visible effects? (Hint: which? the changelog should say that so that the severity of the bug can be judged). Otherwise I agree the bug is there and patch is fixing it. Thanks. > Fixes: df1acc856923 ("mm/page_alloc: avoid conflating IRQs disabled with zone->lock") > Signed-off-by: Doug Berger Acked-by: Vlastimil Babka > --- > mm/page_alloc.c | 25 ++++++++++++------------- > 1 file changed, 12 insertions(+), 13 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 73704e836649..8addb4919f75 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -3436,19 +3436,10 @@ void free_unref_page_list(struct list_head *list) > * comment in free_unref_page. > */ > migratetype = get_pcppage_migratetype(page); > - if (unlikely(migratetype >= MIGRATE_PCPTYPES)) { > - if (unlikely(is_migrate_isolate(migratetype))) { > - list_del(&page->lru); > - free_one_page(page_zone(page), page, pfn, 0, > - migratetype, FPI_NONE); > - continue; > - } > - > - /* > - * Non-isolated types over MIGRATE_PCPTYPES get added > - * to the MIGRATE_MOVABLE pcp list. > - */ > - set_pcppage_migratetype(page, MIGRATE_MOVABLE); > + if (unlikely(is_migrate_isolate(migratetype))) { > + list_del(&page->lru); > + free_one_page(page_zone(page), page, pfn, 0, migratetype, FPI_NONE); > + continue; > } > > set_page_private(page, pfn); > @@ -3458,7 +3449,15 @@ void free_unref_page_list(struct list_head *list) > list_for_each_entry_safe(page, next, list, lru) { > pfn = page_private(page); > set_page_private(page, 0); > + > + /* > + * Non-isolated types over MIGRATE_PCPTYPES get added > + * to the MIGRATE_MOVABLE pcp list. > + */ > migratetype = get_pcppage_migratetype(page); > + if (unlikely(migratetype >= MIGRATE_PCPTYPES)) > + migratetype = MIGRATE_MOVABLE; > + > trace_mm_page_free_batched(page); > free_unref_page_commit(page, pfn, migratetype, 0); > >