From patchwork Thu Oct 31 23:36:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13858492 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 9893CE6748C for ; Thu, 31 Oct 2024 23:36:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 216286B00A1; Thu, 31 Oct 2024 19:36:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C6316B00A5; Thu, 31 Oct 2024 19:36:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 08E616B00A6; Thu, 31 Oct 2024 19:36:18 -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 DF92A6B00A1 for ; Thu, 31 Oct 2024 19:36:17 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8B97981951 for ; Thu, 31 Oct 2024 23:36:17 +0000 (UTC) X-FDA: 82735508142.28.6E22044 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf03.hostedemail.com (Postfix) with ESMTP id 1EA4920007 for ; Thu, 31 Oct 2024 23:36:02 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=jJsxCxHG; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of 3bhQkZwYKCGcXZWJSGLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3bhQkZwYKCGcXZWJSGLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--surenb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730417656; a=rsa-sha256; cv=none; b=6Yi8eG/+2cRMF2DXBVGnQ7yO+3H5sHh9DkTdY92KAF0l4jdBW00Vhmz8y0VQ85gFpx39Fa JG+A6w8fmdRKQ1eePDFSCm0NddQNO80kPf4iACEGq3nfJEUhhciT57ppKqUSE8YvaoQqdg bT0b917zEYW3l0Tb8gLNNzfl1VdRMlM= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=jJsxCxHG; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of 3bhQkZwYKCGcXZWJSGLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3bhQkZwYKCGcXZWJSGLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730417656; 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-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=5Y5D0344T4ayqAf+xnFFDFs3+CjHFh6YQW8dHgLsJq4=; b=yFe+QHmMHg7aAF4K1R/jt25E1SOLnjof/V+DE1fIvAvHVaaBYqvorPI+4hoQBkvAQpd5hR WYdtJ1C94rs+Tm61BklJKh/LUqkMJHBonkwKMibl63MTjoM+hhkbrhIgreOq7ldJbnBbgc EPCQ4AxkafyPJWTCXnMYSL61XwOLwtE= Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e2904d0cad0so2909734276.1 for ; Thu, 31 Oct 2024 16:36:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1730417775; x=1731022575; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=5Y5D0344T4ayqAf+xnFFDFs3+CjHFh6YQW8dHgLsJq4=; b=jJsxCxHGBBrJoXgWGVtxsq/jbzQDVO8fOzCTffBKZ6H5bBI/gXA3Epn0WRUawBq8Df NK7MCTl4xMf+bl5hTugnX3yDT9JXnBBInFqF0Dyxs5em99bv2246vZV5d7N641aqqgm0 X+KWV+F1PnlFoNCXUsCAlYhAAIGS8nxHKmTKo1FkqbSR301mW2n/1xJOsxiZyGBkmvS6 H2TCYstJgh6XY6WOVg8bQrgVlQd2Bmt2zkXfy75IRRhPcD+g/xaj/Y0Nn/iRK5LmbZRj tns6DEaNSbAdDE5u+WqWmkrZ+NBXqBFG6uz0IWZLxxj1xTxvlgkB/djmgYRtKPTyzC5e 9v3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730417775; x=1731022575; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=5Y5D0344T4ayqAf+xnFFDFs3+CjHFh6YQW8dHgLsJq4=; b=Eg3Ri1VraQAVcO32KFlcV2tB+KCf89cbRZnT5g+MfQepxCasWjqb9JIqpIS9msLCxP eRRKBBGpcmlQqsdj11tr1Mr2LCnaiEwaka4vzPRr7j9qm8x0u0hOetLr08HT+6Z37HFU DGJ0kgJc8BzQv0TEx6zKiSAdc6sm4aa0DrGUZ9viSdHGmCWreCsZ5rEOhdEgpfv4VC0q eEOex3rkGXGYku5OKz3l3nUT7RbMs7FLWGfWVdwypzMpMHJ/Dj8spzgS+xXAaiByC8BX U/cIu1HDOjYrH92kP1Sxw2F7rqATsGMuFazkM9MWWyouJ4G2o8c4OG8aF+NMRNu4Hrff Ep6g== X-Forwarded-Encrypted: i=1; AJvYcCUWKwwauoaNRDmLv87DQcuRiusk9aZLNVpSzHTNhZi43h5E3T+WEe90+awZxEOX/niD8Fi30zo8Eg==@kvack.org X-Gm-Message-State: AOJu0Ywsv/WoVniXExJ5u/Rq3wC9p0h18PezLrYbDMls3Yb7hqsnmvHr zorOgLGvXaTbWF8b5ZSnajeXIsqpFE6Yr1d2mNYT/vc9Rt4ErJODmOljVWwTM9xeFkMQXCvMf4F 2lA== X-Google-Smtp-Source: AGHT+IEIPLPP597svzD0H12j4/MSctqmVJ3Xh8xaOC80ggktFHpli3fTeTvFXGthn4t8CrEyjVrHgptevoM= X-Received: from surenb-desktop.mtv.corp.google.com ([2a00:79e0:2e3f:8:1498:a594:2b5d:75e5]) (user=surenb job=sendgmr) by 2002:a25:dc4e:0:b0:e29:6e61:3db4 with SMTP id 3f1490d57ef6-e3302527b97mr1145276.2.1730417774819; Thu, 31 Oct 2024 16:36:14 -0700 (PDT) Date: Thu, 31 Oct 2024 16:36:11 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Message-ID: <20241031233611.3833002-1-surenb@google.com> Subject: [PATCH v2 1/1] alloc_tag: avoid execmem_vmap() when !MMU From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: arnd@kernel.org, arnd@arndb.de, rppt@kernel.org, pasha.tatashin@soleen.com, mcgrof@kernel.org, song@kernel.org, mhiramat@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, surenb@google.com, kernel test robot X-Rspamd-Queue-Id: 1EA4920007 X-Stat-Signature: qw5u9w8chu5wu14y6tot7jkc6uqrig1h X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1730417762-885547 X-HE-Meta: U2FsdGVkX1+a7o74Y5rncUKkfGimbmYB68CpXEpnAaN95+v7u9Gm+4uE+GWay0+VlWGV8EBUc9amtrdcsYf7YgPtUn/QVGMIIRXymXAHpM0NTbzT9Y2WL4y6Q6vanrAfjGS1Vm/ljX3A3zF6xCn3bcFYFL5q/pdlRT4RasX2ZQ9+eqdiIpJVyqQx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fZZPEwH/qdgml327Gq/NGeTGuG/yz6qa9R0NlWFt00JTbibNr7arTtdCPkrT2bVSwDTLcTV76ak7XiYppstnPVyWC7ue7M5AndklKSh812ejoZBDY0DsJu5C54xfuanPfiZ1QjEzTH3Wl1CDBBymHrJxgKgTe3d/I4SelAbBBuqtzWn1+FSJYhkA25PNTR1pAw4G6oN3fotI4GR4Ji0fdCtIZe9LDX3QFnNq1EZQtjZdVWIxI31N2HEYRGtoG3pUt45E+hBTSofnWNb7hibmOUHSEuTwgphadbjuHOBsU1DB+RKYUYIE7AU9VD3YQKNZ66uSVfbQqWkvQcGpsys4Lz8Cd7EjuefvDFgJAutpcgYiVPbM/G11zB97bTVyvMNICWil7vUREawcW3PPih9dH8DSUVcgC3fiT9HscUuX0xxKK3z1ew0= 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: List-Subscribe: List-Unsubscribe: With CONFIG_MMU=n __get_vm_area_node() is not available. Add CONFIG_MMU dependency for memory allocation tagging since it uses __get_vm_area_node() via execmem_vmap(). Fixes: 57bc3834fb6f ("alloc_tag: populate memory for module tags as needed") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202410250808.dQGyYjlk-lkp@intel.com/ Closes: https://lore.kernel.org/oe-lkp/202410251525.9f85854d-oliver.sang@intel.com Closes: https://lore.kernel.org/oe-kbuild-all/202410261016.IO7C6Cml-lkp@intel.com/ Closes: https://lore.kernel.org/oe-kbuild-all/202410270919.LebQlmxD-lkp@intel.com/ Suggested-by: Mike Rapoport (Microsoft) Signed-off-by: Suren Baghdasaryan Cc: Arnd Bergmann --- Replaces old version with the same name in mm-unstable (current SHA 88e136f0950d) Changes since v1 [1] - drop support for (CONFIG_MEM_ALLOC_PROFILING && !CONFIG_MMU) to simplify the change, per Mike Rapoport [1] https://lore.kernel.org/all/20241028202935.1047017-1-surenb@google.com/ include/linux/execmem.h | 2 ++ lib/Kconfig.debug | 1 + mm/execmem.c | 32 ++++++++++++++++---------------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/include/linux/execmem.h b/include/linux/execmem.h index 5a5e2917f870..64130ae19690 100644 --- a/include/linux/execmem.h +++ b/include/linux/execmem.h @@ -139,6 +139,7 @@ void *execmem_alloc(enum execmem_type type, size_t size); */ void execmem_free(void *ptr); +#ifdef CONFIG_MMU /** * execmem_vmap - create virtual mapping for EXECMEM_MODULE_DATA memory * @size: size of the virtual mapping in bytes @@ -148,6 +149,7 @@ void execmem_free(void *ptr); * Return: the area descriptor on success or %NULL on failure. */ struct vm_struct *execmem_vmap(size_t size); +#endif /** * execmem_update_copy - copy an update to executable memory diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 7312ae7c3cc5..6798bbbcbd32 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -993,6 +993,7 @@ config CODE_TAGGING config MEM_ALLOC_PROFILING bool "Enable memory allocation profiling" default n + depends on MMU depends on PROC_FS depends on !DEBUG_FORCE_WEAK_PER_CPU select CODE_TAGGING diff --git a/mm/execmem.c b/mm/execmem.c index 5c0f9f2d6f83..317b6a8d35be 100644 --- a/mm/execmem.c +++ b/mm/execmem.c @@ -64,6 +64,22 @@ static void *execmem_vmalloc(struct execmem_range *range, size_t size, return p; } + +struct vm_struct *execmem_vmap(size_t size) +{ + struct execmem_range *range = &execmem_info->ranges[EXECMEM_MODULE_DATA]; + struct vm_struct *area; + + area = __get_vm_area_node(size, range->alignment, PAGE_SHIFT, VM_ALLOC, + range->start, range->end, NUMA_NO_NODE, + GFP_KERNEL, __builtin_return_address(0)); + if (!area && range->fallback_start) + area = __get_vm_area_node(size, range->alignment, PAGE_SHIFT, VM_ALLOC, + range->fallback_start, range->fallback_end, + NUMA_NO_NODE, GFP_KERNEL, __builtin_return_address(0)); + + return area; +} #else static void *execmem_vmalloc(struct execmem_range *range, size_t size, pgprot_t pgprot, unsigned long vm_flags) @@ -368,22 +384,6 @@ void execmem_free(void *ptr) vfree(ptr); } -struct vm_struct *execmem_vmap(size_t size) -{ - struct execmem_range *range = &execmem_info->ranges[EXECMEM_MODULE_DATA]; - struct vm_struct *area; - - area = __get_vm_area_node(size, range->alignment, PAGE_SHIFT, VM_ALLOC, - range->start, range->end, NUMA_NO_NODE, - GFP_KERNEL, __builtin_return_address(0)); - if (!area && range->fallback_start) - area = __get_vm_area_node(size, range->alignment, PAGE_SHIFT, VM_ALLOC, - range->fallback_start, range->fallback_end, - NUMA_NO_NODE, GFP_KERNEL, __builtin_return_address(0)); - - return area; -} - void *execmem_update_copy(void *dst, const void *src, size_t size) { return text_poke_copy(dst, src, size);