From patchwork Thu Mar 30 11:49:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A . Shutemov" X-Patchwork-Id: 13194067 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 F2F71C77B60 for ; Thu, 30 Mar 2023 11:50:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 87EEF6B0074; Thu, 30 Mar 2023 07:50:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 807AF6B0075; Thu, 30 Mar 2023 07:50:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6CEE66B0078; Thu, 30 Mar 2023 07:50:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5EA2D6B0074 for ; Thu, 30 Mar 2023 07:50:33 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1F5151403C0 for ; Thu, 30 Mar 2023 11:50:33 +0000 (UTC) X-FDA: 80625397146.25.1AF53AE Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by imf16.hostedemail.com (Postfix) with ESMTP id 0BB44180006 for ; Thu, 30 Mar 2023 11:50:30 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=jJl+1eQB; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf16.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 134.134.136.24) smtp.mailfrom=kirill.shutemov@linux.intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680177031; 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=3Xcx87+8at3w01ECUa4i8O3uXEYYImpaB9iORG5znps=; b=NquOq9PkBOww+nMMO/P6OHc9Y5cC7wjJ8VjJGBWw62fEG+67KendE6OYeFhDykhk4jhBCW FnaNuP18KB1mW9zBfQdWx9nS8es9d6XeE5RhDYSVjVkWL/Uurk7kgyBmr4cbW2aG4MnDmo IlCX6FbzVXnSagcWDDu6HQcLzjLL1hA= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=jJl+1eQB; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf16.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 134.134.136.24) smtp.mailfrom=kirill.shutemov@linux.intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680177031; a=rsa-sha256; cv=none; b=QPu5MbQR4G0t4ElSKYTQTyX2aZgovK/NYmDyCpSB97JwSbXUyY+mRr1S2za360rAqqxiQw LI8lBQG+Soy/lnnXlTFpmkcVEj6qCbiW6cJiQ+J9ykMVi7+56LExILqRejdvP2fn+P6TLG NimrFRUkpcyvRBaMe28TMqS5vJlmb+0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680177031; x=1711713031; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=j9rCoZtseVkMxXJK20bhOG6vjoCUVN6BwYUe9lsjGyo=; b=jJl+1eQBQQejUCWSPKVgpFg5Jv+fiP9ujTka/dwPCrfhnD91l75vC2V8 lYfxcAbCGvzB38MWhmthHwv9kTLOW4E3jqrYUwkMOCobSZNZOMLBvGbUC C3PTnNzbh+zxpI2FkevBtvAZUwgHoD/jnoo6Lh6nSqBh3LRU8O/TMQOsB KZB0g/YoOI8GMZMBrY7j32QTX13PuynkQPl7ZFTHRi7nY+5TnkWePUzL7 gTeQ8IytE/wF2ZgtFjGm80AIpuo00av31vjZ84psxZaeqNmgAfpfPny0g tCMn6OoqodBOJ6BwqxAWgOkaHisvCpK3HJVZb4hVuzhooVm0I+WHHYzYH Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10664"; a="342756721" X-IronPort-AV: E=Sophos;i="5.98,303,1673942400"; d="scan'208";a="342756721" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Mar 2023 04:50:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10664"; a="634856482" X-IronPort-AV: E=Sophos;i="5.98,303,1673942400"; d="scan'208";a="634856482" Received: from ngreburx-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.251.209.91]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Mar 2023 04:50:02 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id 0612B10438E; Thu, 30 Mar 2023 14:50:00 +0300 (+03) From: "Kirill A. Shutemov" To: Borislav Petkov , Andy Lutomirski , Sean Christopherson , Andrew Morton , Joerg Roedel , Ard Biesheuvel Cc: Andi Kleen , Kuppuswamy Sathyanarayanan , David Rientjes , Vlastimil Babka , Tom Lendacky , Thomas Gleixner , Peter Zijlstra , Paolo Bonzini , Ingo Molnar , Dario Faggioli , Dave Hansen , Mike Rapoport , David Hildenbrand , Mel Gorman , marcelo.cerri@canonical.com, tim.gardner@canonical.com, khalid.elmously@canonical.com, philip.cox@canonical.com, aarcange@redhat.com, peterx@redhat.com, x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCHv9 03/14] mm/page_alloc: Fake unaccepted memory Date: Thu, 30 Mar 2023 14:49:45 +0300 Message-Id: <20230330114956.20342-4-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230330114956.20342-1-kirill.shutemov@linux.intel.com> References: <20230330114956.20342-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 0BB44180006 X-Stat-Signature: fc1xr7p94xtocbkqg5tzp8pgfw3o9c9d X-HE-Tag: 1680177030-114844 X-HE-Meta: U2FsdGVkX1/atePPej1p2GmGpR4Pr/mWeyj1kkUGStGwdTvYcpW1DgfnBlC8s0aI1yXut49cXfVEGx/kOYrbR1Q+91p4tizrZlIYk28bOVZFUZr2DsZKKXaLDDEofjBlCb1A1Lqcz2YcMD1VhcD59dhLiyXZHuQS7u6YcQLuKnP8TzyuAmuJZtL6z0BI5tNRnmvLUB6im0BqsK6BF3Y3QWXWhmcHNX5N4aBktdKk5vPK1nbaaThIh8kzJ4Bs9jikNF1tZPGjQ/8VKTnH1pneYISuWUiGI7wmkwweBGX0C1LeymXz0z8JEJButkJDf9U/SwfN+KD35OjN8mATTtrElSwTKApxZ7lIp5cvlHzfu3B45gDzK4gTTYq1iD+dBAcoteZBWhnNysTueGh73dm+TK2Sc+nNmks1NTZcl7PBI/uXYcq2k8EX8d5xTniJUwtj/GxgK5QisdtYqEbO8rdzEZ60o30UZXTRZYGVYyoMoektmOc3PiFS6f1ad0uymiMSgZ5VXarbKRFClLkDJTvGi2xojl3mFJB0qp8J5XiEjjUJmdSgvjGwtTfUq3SzhoAqdj8CoSZXcEW7G5GwxVj7cZsOgMck6Btf+uvwkzG7Juul+C5yLpSXBjoMuvTCLvMCdd6Is12YE8C4CPK6G1ePlS4688RGCc77sr5Rdlyo7cSDcxFZbKw2gHlYpWOykJNQS43ZpVOrrzBsn2T0hhP5Srqssk+KZZYQcveynATXO4AWOihCmJtXVLIUFdmoo+fDzDm02lbKvFWqxwtn9DoVuzJ11sK+UhzOUv54/OQ6J9Kzxkg1cEW3aQZYrQNsXdF+FPBl8IPkkDL4qXUcrtejo1bNHnsBiUOu5647L8l49hQpVJGRoxgZ6k/Vr3NcO+3gVOKbEmpY5S7P7rYaWFPEIzlcvReJselTRSncjIiXHUuY7NHfHcYvAsVn2tqDWqFN3Zpn/Dm3H//SnAwYEpW LWlEnk7d NqmDLXrtscSP1VBzgfX240kVxEbc09n9wso1uMdl/cRMzIbgX/AFnTl7EKbI+wQlGi2/DgHWlRX55GVuNcZCcu75B/28Yl2t4BYoAH+TfkssNagXqOEdnEixSnHIosbbld6E3KKrYkh7Mzn+z+DjClJm/cQQ8jLSNg4PssieJiUdsQU12By98vjdzku+NJqs8XOgxgloSMShQg0k= 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: For testing purposes, it is useful to fake unaccepted memory in the system. It helps to understand unaccepted memory overhead to the page allocator. The patch allows to treat memory above the specified physical memory address as unaccepted. The change only fakes unaccepted memory for page allocator. Memblock is not affected. It also assumes that arch-provided accept_memory() on already accepted memory is a nop. Signed-off-by: Kirill A. Shutemov --- mm/page_alloc.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index d62fcb2f28bd..509a93b7e5af 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7213,6 +7213,8 @@ static DEFINE_STATIC_KEY_FALSE(zones_with_unaccepted_pages); static bool lazy_accept = true; +static unsigned long fake_unaccepted_start = -1UL; + static int __init accept_memory_parse(char *p) { if (!strcmp(p, "lazy")) { @@ -7227,11 +7229,30 @@ static int __init accept_memory_parse(char *p) } early_param("accept_memory", accept_memory_parse); +static int __init fake_unaccepted_start_parse(char *p) +{ + if (!p) + return -EINVAL; + + fake_unaccepted_start = memparse(p, &p); + + if (*p != '\0') { + fake_unaccepted_start = -1UL; + return -EINVAL; + } + + return 0; +} +early_param("fake_unaccepted_start", fake_unaccepted_start_parse); + static bool page_contains_unaccepted(struct page *page, unsigned int order) { phys_addr_t start = page_to_phys(page); phys_addr_t end = start + (PAGE_SIZE << order); + if (start >= fake_unaccepted_start) + return true; + return range_contains_unaccepted_memory(start, end); }