From patchwork Mon Oct 24 13:41:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Wandun X-Patchwork-Id: 13017595 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 1F72CFA3740 for ; Mon, 24 Oct 2022 13:16:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7945E8E0002; Mon, 24 Oct 2022 09:16:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 744748E0001; Mon, 24 Oct 2022 09:16:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 632FB8E0002; Mon, 24 Oct 2022 09:16:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 5146D8E0001 for ; Mon, 24 Oct 2022 09:16:15 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id F04E8A0B53 for ; Mon, 24 Oct 2022 13:16:14 +0000 (UTC) X-FDA: 80055891468.12.AD8080F Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf29.hostedemail.com (Postfix) with ESMTP id E3FCF120045 for ; Mon, 24 Oct 2022 13:16:11 +0000 (UTC) Received: from dggpemm500021.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MwwSL75lwzmVMr; Mon, 24 Oct 2022 21:11:14 +0800 (CST) Received: from dggpemm500002.china.huawei.com (7.185.36.229) by dggpemm500021.china.huawei.com (7.185.36.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 24 Oct 2022 21:16:05 +0800 Received: from localhost.localdomain (10.175.112.125) by dggpemm500002.china.huawei.com (7.185.36.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 24 Oct 2022 21:16:05 +0800 From: Chen Wandun To: , , , , , Subject: [PATCH] mm: fix pcp count beyond pcp high in pcplist allocation Date: Mon, 24 Oct 2022 21:41:46 +0800 Message-ID: <20221024134146.3442393-1-chenwandun@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500002.china.huawei.com (7.185.36.229) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; spf=pass (imf29.hostedemail.com: domain of chenwandun@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=chenwandun@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666617373; a=rsa-sha256; cv=none; b=c/ISNSP/lpcfubyj7X7dwrIq2h+Df8nQBX+ey6DlYvZJv/0N7pNNbp7mDgqRSkxEUx7LmO +erCTOK6kFi/CEt+og/tW4G4ZKBCW9/hynqf97KAZoQf+GOokmBsIl82PbpfKaCcDh0EAu Mb2vZylhH4jP1l20N8fjKlH/yH2nvHM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666617373; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=ePBws6xZpUqCWuNS3hy0Y16aFjxCqqTx3X1LBGvn5Ds=; b=RCaRfK9TPcXGqVf2cDACu9UpCkw3gP0n40Pqe2TU6QjknU3qiqIcoxMiAub7CQ7FQX41Bq BjPpUS1h///pT0Kax7ZkpVKwA3bRiE18NFmRjjtQiTeDahnj5r27zY68xHm3aw6GprQmdk KmfYdZ37qQ+AZ65UOHfI1EQtmnSGnOU= X-Rspamd-Queue-Id: E3FCF120045 X-Rspam-User: Authentication-Results: imf29.hostedemail.com; dkim=none; spf=pass (imf29.hostedemail.com: domain of chenwandun@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=chenwandun@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspamd-Server: rspam11 X-Stat-Signature: 33xg3kk9jkuq5rwehqqny1c4rjym3zc3 X-HE-Tag: 1666617371-4190 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: Nowadays there are several orders in pcplist, Function __rmqueue_pcplist would alloc pcp batch pages to refill pcplist, when list of target order if empty meanwhile other lists is not all empty, that result in pcp count beyond pcp high after allocation. This behaviour can be easily observed by adding debugging information in __rmqueue_pcplist. Fix this by recalculate the batch pages to be allocated. Fixes: 44042b449872 ("mm/page_alloc: allow high-order pages to be stored on the per-cpu lists") Signed-off-by: Chen Wandun --- mm/page_alloc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 39f846d098f5..93e18b6de2f3 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3742,6 +3742,7 @@ struct page *__rmqueue_pcplist(struct zone *zone, unsigned int order, do { if (list_empty(list)) { int batch = READ_ONCE(pcp->batch); + int high = READ_ONCE(pcp->high); int alloced; /* @@ -3753,6 +3754,7 @@ struct page *__rmqueue_pcplist(struct zone *zone, unsigned int order, */ if (batch > 1) batch = max(batch >> order, 2); + batch = min(batch, (high - pcp->count) >> order); alloced = rmqueue_bulk(zone, order, batch, list, migratetype, alloc_flags);