From patchwork Tue Apr 18 19:13:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 13216114 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 F244FC77B75 for ; Tue, 18 Apr 2023 19:14:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0833828000B; Tue, 18 Apr 2023 15:13:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ED852280001; Tue, 18 Apr 2023 15:13:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D2AB928000B; Tue, 18 Apr 2023 15:13:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C01A2280001 for ; Tue, 18 Apr 2023 15:13:52 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 9FBE21A0402 for ; Tue, 18 Apr 2023 19:13:52 +0000 (UTC) X-FDA: 80695461504.23.F8AAA2C Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) by imf12.hostedemail.com (Postfix) with ESMTP id C330F40013 for ; Tue, 18 Apr 2023 19:13:50 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=cmpxchg-org.20221208.gappssmtp.com header.s=20221208 header.b=A6AezfgF; spf=pass (imf12.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.170 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681845230; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qWzWNVwkSkX/nKeV3fr2KFPOgnXDvxLFllKcLvZxGIY=; b=mIBETa8L3SWB0z//37ZbPEMEE5O4ue5cObmBc9GBgectf9M5Fa5TZD8B/tm3DviHMNcopJ gkincfCab0LXMu8G/V8dbHiVYwfVHKxwBNxvOMdo2qo/qBZN18NALWJxmmlHO7Oavn+dbR KChBRS898RtZt7ucSpH7Asjz4wvmPS0= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=cmpxchg-org.20221208.gappssmtp.com header.s=20221208 header.b=A6AezfgF; spf=pass (imf12.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.170 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681845230; a=rsa-sha256; cv=none; b=d64yGwch5BytfMpNbrSINt3twZNeg2tJdkFcG5k5VMe6Ish0MZznrmz/XN5c+9WNizgTuc eT3/87mx3hwRR4BYBWcEIywXbc0RaOjX1jxCBW6jXOQTez/7T2LZYy2fS74o5M9V3fuLP/ efAuNjmWDsuHougtCXMthbP2mRDmShg= Received: by mail-qt1-f170.google.com with SMTP id ei23so1769759qtb.2 for ; Tue, 18 Apr 2023 12:13:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20221208.gappssmtp.com; s=20221208; t=1681845229; x=1684437229; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qWzWNVwkSkX/nKeV3fr2KFPOgnXDvxLFllKcLvZxGIY=; b=A6AezfgFb558g3zl8KYkj4x8/L0DIOCUiDlAuiOpPB/uNdrligymciqY3pviiovSz7 vKSf382DQ8ssov3wdJ9qL3nD7oIEAgvToPUv9CYpTlO4HbTHGzp2IZTc2DXrdM3mXahz 0py57a20ojr2O+PepMwl9/QHioEm1FDw2MRiTZYyYWKB9AsL5d0proRbKpQwyYUfMNP1 //zhEeIOanhXcaehUnWf/FVKyKlOdRk3NVSIwARpSIl5m2koxzkBtGtcG0JMTTTieE93 AO69YNUjxBNNIS0LLC1PusXdBE3chI7eqcQajUcD2Uoo7NcibA/0DG0uhwzJHlI926dN p8uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681845229; x=1684437229; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qWzWNVwkSkX/nKeV3fr2KFPOgnXDvxLFllKcLvZxGIY=; b=aa4zlzJ5U2+EOZk//HZNiBSuSO7nAk3GFKHnut5+6wKiORbNWwFs0gMxxJRBW7yfmw PvFpyyDirN14oawnqbrixnETR1SQE8ky3VXYhZB/aEi4rHML9jqB2qMod7s1qYcjsaF8 p7LF+KwvPNUFKUwQgDv+BudHSwJ+FQ/CCvRXKiljNLL91ULcUBXKHS0NUYHXdWo1oGUs pYRI2+zANhq4YmWxuu/1cvDqIodciO6AokAngOlEnqWdgvbJ0wu3qhEcnvyDjSCOhrBz jV1VGn+7KfYVTWZMY9p+zGns15XBKf36FgBNRIhwftD2/i+VHdK1I8L3BX+BZPGd+qQh pVfg== X-Gm-Message-State: AAQBX9e36OIEQ9yoDoO6iLHCcuSNFaqhZEK0wHTy/E4CwaOzKdrM5Qm2 ODWNO/mi5sMTyga+o0LZ0ZIK8K5DIY/1GUB/fuw= X-Google-Smtp-Source: AKy350ZdZcMKMoHMrh8Lve5YppGzlgXCzZWIFyu+Z0bcXvlyOp64kIBGTX1A+KzTiCSPMF180KBHNA== X-Received: by 2002:a05:622a:4a:b0:3b8:6ca4:bb23 with SMTP id y10-20020a05622a004a00b003b86ca4bb23mr1454631qtw.15.1681845229705; Tue, 18 Apr 2023 12:13:49 -0700 (PDT) Received: from localhost ([2620:10d:c091:400::5:e646]) by smtp.gmail.com with ESMTPSA id d9-20020ac81189000000b003eb136bec50sm3482413qtj.66.2023.04.18.12.13.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 12:13:49 -0700 (PDT) From: Johannes Weiner To: linux-mm@kvack.org Cc: Kaiyang Zhao , Mel Gorman , Vlastimil Babka , David Rientjes , linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [RFC PATCH 26/26] mm: page_alloc: add sanity checks for migratetypes Date: Tue, 18 Apr 2023 15:13:13 -0400 Message-Id: <20230418191313.268131-27-hannes@cmpxchg.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230418191313.268131-1-hannes@cmpxchg.org> References: <20230418191313.268131-1-hannes@cmpxchg.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: C330F40013 X-Stat-Signature: y5z1y9ub37n5sozh8zoq9dyaguh85uwg X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1681845230-978066 X-HE-Meta: U2FsdGVkX18dgc1TDIymCeqM04ikqc7vcmcEuX4cMjh9ICr3Y6UIjQdPAX8Jr1H7Bth6hfeTq847mjcEgdVp+gXeI7rXk2K6nzb3Un8GNe6lXZfdyFVjZBLxmtDUxSqZV/vfBJ4tcOf8MsVTS59J+dKIdSJL6ED4OCg9LFfXL6EdMTXNP7RlKn5/0gf2skcDiuNgDRG3mFzmKry5B2RPkkeZEF2Wor7mAbgVuII4eRbiNaS8CL+3jfZO6//WH56Fy5XC2q8AHamEm0AbJbFnUNinlvAoPxo7bWbD/z8feewU+hko4EEZl5WIG00U6Q4aehf794+COXXPifJCoARAn/+GS7qzusVlKc1StQ6C9czmuZo20N1LG22cvgIOkbxq4RUKbT0uKimxFRSXiA6BEztUXHEi8gO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+tr3pw8LPFoZd0b8GeFmQ== 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: Now that known block pollution from fallbacks, !movable compaction, highatomic reserves and single THP pcplists is gone, add high-level sanity checks that ensure that pages coming out of the allocator are of the requested migratetype. Signed-off-by: Johannes Weiner --- mm/page_alloc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 9db588a1de3b..b8767a6075e8 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3675,6 +3675,7 @@ struct page *rmqueue(struct zone *preferred_zone, int migratetype) { struct page *page; + int buddy = 0; /* * We most definitely don't want callers attempting to @@ -3698,9 +3699,14 @@ struct page *rmqueue(struct zone *preferred_zone, page = rmqueue_buddy(preferred_zone, zone, order, alloc_flags, migratetype); + buddy = 1; out: VM_BUG_ON_PAGE(page && bad_range(zone, page), page); + VM_WARN_ONCE(page && get_pageblock_migratetype(page) != migratetype, + "%d:%s order=%u gfp=%pGg mt=%s alloc_flags=%x buddy=%d\n", + zone_to_nid(zone), zone->name, order, &gfp_flags, + migratetype_names[migratetype], alloc_flags, buddy); return page; }