From patchwork Thu Feb 10 06:41:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Liu X-Patchwork-Id: 12741438 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 7B413C433FE for ; Thu, 10 Feb 2022 06:41:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 841F76B0071; Thu, 10 Feb 2022 01:41:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F1906B0074; Thu, 10 Feb 2022 01:41:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6DFF06B0075; Thu, 10 Feb 2022 01:41:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0028.hostedemail.com [216.40.44.28]) by kanga.kvack.org (Postfix) with ESMTP id 5B8D56B0071 for ; Thu, 10 Feb 2022 01:41:28 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 03E19181BC81D for ; Thu, 10 Feb 2022 06:41:27 +0000 (UTC) X-FDA: 79125923856.18.42A978E Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf25.hostedemail.com (Postfix) with ESMTP id 6F4A0A0004 for ; Thu, 10 Feb 2022 06:41:27 +0000 (UTC) Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.16.1.2/8.16.1.2) with ESMTP id 219NYHAj002462 for ; Wed, 9 Feb 2022 22:41:26 -0800 Received: from maileast.thefacebook.com ([163.114.130.16]) by m0089730.ppops.net (PPS) with ESMTPS id 3e4ha0cp0n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 09 Feb 2022 22:41:26 -0800 Received: from twshared22811.39.frc1.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Wed, 9 Feb 2022 22:41:25 -0800 Received: by devbig006.ftw2.facebook.com (Postfix, from userid 4523) id 42D8229D423BF; Wed, 9 Feb 2022 22:41:19 -0800 (PST) From: Song Liu To: , , CC: , , , , , , Song Liu Subject: [PATCH bpf-next 1/2] vmalloc: expose vmap_allow_huge via get_vmap_allow_huge() Date: Wed, 9 Feb 2022 22:41:07 -0800 Message-ID: <20220210064108.1095847-2-song@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220210064108.1095847-1-song@kernel.org> References: <20220210064108.1095847-1-song@kernel.org> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: xNswPOdjahqhKiHYWQm49BuMXPaGemTV X-Proofpoint-GUID: xNswPOdjahqhKiHYWQm49BuMXPaGemTV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-10_02,2022-02-09_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=fb_outbound_notspam policy=fb_outbound score=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 spamscore=0 malwarescore=0 mlxscore=0 suspectscore=0 impostorscore=0 clxscore=1011 mlxlogscore=999 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202100034 X-FB-Internal: deliver X-Rspamd-Queue-Id: 6F4A0A0004 Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=kernel.org (policy=none); spf=none (imf25.hostedemail.com: domain of "prvs=30401ac2be=songliubraving@fb.com" has no SPF policy when checking 67.231.153.30) smtp.mailfrom="prvs=30401ac2be=songliubraving@fb.com" X-Stat-Signature: wp64z5kcpoqparbqf3dcb365ghs6w9f5 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1644475287-182424 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: Users can use get_vmap_allow_huge() to predict the behavior of vmalloc (or its variations). Specifically, if get_vmap_allow_huge() == false, vmalloc will never return huge pages. Signed-off-by: Song Liu --- include/linux/vmalloc.h | 1 + mm/vmalloc.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index 880227b9f044..22acfcd2d0d1 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -256,6 +256,7 @@ extern long vread(char *buf, char *addr, unsigned long count); extern struct list_head vmap_area_list; extern __init void vm_area_add_early(struct vm_struct *vm); extern __init void vm_area_register_early(struct vm_struct *vm, size_t align); +extern bool get_vmap_allow_huge(void); #ifdef CONFIG_SMP # ifdef CONFIG_MMU diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 4165304d3547..895ac81b6bb4 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -72,6 +72,11 @@ early_param("nohugevmalloc", set_nohugevmalloc); static const bool vmap_allow_huge = false; #endif /* CONFIG_HAVE_ARCH_HUGE_VMALLOC */ +bool get_vmap_allow_huge(void) +{ + return vmap_allow_huge; +} + bool is_vmalloc_addr(const void *x) { unsigned long addr = (unsigned long)x;