From patchwork Wed Aug 11 18:29:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 12431705 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 4F7D5C4320A for ; Wed, 11 Aug 2021 18:29:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B2876610A8 for ; Wed, 11 Aug 2021 18:29:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B2876610A8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 112168D0001; Wed, 11 Aug 2021 14:29:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C3206B0072; Wed, 11 Aug 2021 14:29:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF2FD8D0001; Wed, 11 Aug 2021 14:29:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0041.hostedemail.com [216.40.44.41]) by kanga.kvack.org (Postfix) with ESMTP id D2FCC6B0071 for ; Wed, 11 Aug 2021 14:29:42 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 758AC18019F1E for ; Wed, 11 Aug 2021 18:29:42 +0000 (UTC) X-FDA: 78463638204.10.A2164F0 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by imf14.hostedemail.com (Postfix) with ESMTP id 0BE46601508E for ; Wed, 11 Aug 2021 18:29:41 +0000 (UTC) Received: by mail-pj1-f47.google.com with SMTP id cp15-20020a17090afb8fb029017891959dcbso11020183pjb.2 for ; Wed, 11 Aug 2021 11:29:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5u5xWf8fH3lSDD8C8CeQ89dIv41ElE5n6uIfcU9ZCf0=; b=SPHtAE3CUi+rHIK5iZyiYptiSl8gQKF9kMsJgVM24KkKJCa1JQizODARByJfyUMKjI m/fCdSV9wzSR0AxmIEhpuMNsDoTbA72TEsStL5DEn9xantDelFldkGcEaJrdGn9NqrWn wlqPZh9/BT2mBRlISvu7t9Nv6RQeN82cJnmr0VGlRbnzczZRN5XlaKyTznWRUqKZFPlT InPUM1ejaR748oXOLc0Q12dp4XSvhnBMln4o69ugeNZ/6uZwHKhJzOCt+x0J6VVgRIO3 6yt4e51bwgsjuv8y8XMKLO5OtHOZxZkve+abSgmKAWDVsdzdgpo++40P/ldzur6EOXLu HQ/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5u5xWf8fH3lSDD8C8CeQ89dIv41ElE5n6uIfcU9ZCf0=; b=nZy7VSsNOrS8h8Vg+41IaW/9ol1uSw82Alzo4EG37bmCzUYr7VJFz6jOQzfLhGYZzv +iWYuQRBBiFcaAc9Nn+lidbg030U0qJUzDAtG6qTDZArm+pvYHF+vBmyLaXpzf5Au9jY ydG/zPdRXB1eXH0C3zpMTfrk3eTfN7+ugyrHMoIkhmzBIOZBKkeuxshVGXd5KOBmhNWW 2WhC/jvj29Rv1l7e1L30Zq5nq5Px7xyuinbyGB5I7XOyvZ43rXkM1A0cLbejxP4RkrEW xgT9nf0UzVTU3kZiDmfr5Qr3zflCXFbzrBMJrIEXQxjTarNBaY9Z9BzfRH7SfhMwwN3a 43Uw== X-Gm-Message-State: AOAM531kyr3z9tHSl5HEGvADNSmz+OjyLnqQUe7SU4E3QtylZJUnKzFv eMmVVVGSIV6jHO0f3QyL4m4= X-Google-Smtp-Source: ABdhPJxxIHRrDtXqLi/qTsWb+Zgdqd50Jz8EuJWohWLL0TeLkI52sgnhvnQkkcgJvqwc6oJz04yK2Q== X-Received: by 2002:a17:903:3091:b029:12d:6927:9ff4 with SMTP id u17-20020a1709033091b029012d69279ff4mr218791plc.1.1628706580923; Wed, 11 Aug 2021 11:29:40 -0700 (PDT) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id j128sm241653pfd.38.2021.08.11.11.29.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Aug 2021 11:29:40 -0700 (PDT) From: Doug Berger To: Andrew Morton Cc: Vlastimil Babka , Mel Gorman , "Peter Zijlstra (Intel)" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Doug Berger Subject: [PATCH] mm/page_alloc: don't corrupt pcppage_migratetype Date: Wed, 11 Aug 2021 11:29:17 -0700 Message-Id: <20210811182917.2607994-1-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=SPHtAE3C; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf14.hostedemail.com: domain of opendmb@gmail.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=opendmb@gmail.com X-Stat-Signature: 4i8i5h6b7kkwbwmaa3renuifa9oe6pa1 X-Rspamd-Queue-Id: 0BE46601508E X-Rspamd-Server: rspam05 X-HE-Tag: 1628706581-739722 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: 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. Fixes: df1acc856923 ("mm/page_alloc: avoid conflating IRQs disabled with zone->lock") Signed-off-by: Doug Berger Acked-by: Vlastimil Babka Acked-by: Mel Gorman --- 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);