From patchwork Thu Jul 25 01:41:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13741498 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 0DE49C3DA63 for ; Thu, 25 Jul 2024 01:42:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B2B026B0089; Wed, 24 Jul 2024 21:42:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ADA806B0092; Wed, 24 Jul 2024 21:42:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92BF86B008C; Wed, 24 Jul 2024 21:42:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 73EDA6B0088 for ; Wed, 24 Jul 2024 21:42:08 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2F1BE160D11 for ; Thu, 25 Jul 2024 01:42:08 +0000 (UTC) X-FDA: 82376574336.21.2547B07 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) by imf19.hostedemail.com (Postfix) with ESMTP id 634501A001C for ; Thu, 25 Jul 2024 01:42:06 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=FuF1nDb5; spf=pass (imf19.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.42 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721871677; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references:dkim-signature; bh=ARX0cQSlFVlhm2JIEi3wscjUVQ/KZdEKGbbJxa4tmRY=; b=tIkGA0cy6vK1WUgaSwIX5Gv+F5qIrxt1b1++m3qLawes5TOhX5gJTFZzWXNj8q2+pid4/c 2+3arpGT51NSBVCgmo5/afuy1c7YsKrx9xVpT842t3cy7XvYuH4VcNSRIj5EGCZyDeB1oU oh4Ngjk0adPWX6z0RztxRsFtJzfbBa0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721871677; a=rsa-sha256; cv=none; b=CC9in93J16t1EMS8X1otc/ucpVRUGC0q/j41loHWbaXpqMsUF10mRTIPiNRs4HExyd0QSW HTMu46Yh7XKY3sChOx/bufpDIajCnEwfS11MsZx7pkkXaSX53uu/HfMuQqEKfrnBOMjwDc VWG5RFq3YRu1n8q6u0/yYtJUEqtGCm4= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=FuF1nDb5; spf=pass (imf19.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.42 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a7a9185e1c0so3468166b.1 for ; Wed, 24 Jul 2024 18:42:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721871725; x=1722476525; darn=kvack.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=ARX0cQSlFVlhm2JIEi3wscjUVQ/KZdEKGbbJxa4tmRY=; b=FuF1nDb55MYBjSVBWSGBZXyjvIcgPD8d8hqVXvczf5nQ1UbaHUcRfo6DQ/LpmA1DLe PMw8p+t8uWOeIzCo66zpHQhK96eEfw8TgIN6E/M9bK58zTOCg2WGD0lZc6Owr0OP71X4 TtMpfbTAJvdlvvXRt+f2PNBcBB/j7lJ4NIGgnTT4X9tHfY6v4tDWKkmRHOW1xFHJiwd8 2rnMyv3nHipUHphnswn0a8Rh59Vwpn0ORGU4pXvFz/uI5TdeCr24d2cz7v7IOBRMOMu6 fEJX5kNpKM8hKONpawM+k/fOIYHsUxkn7ED2a5d0BgXtr5hQ8t68zp4/q70Ng52GXgmJ V1tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721871725; x=1722476525; h=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=ARX0cQSlFVlhm2JIEi3wscjUVQ/KZdEKGbbJxa4tmRY=; b=nHvFv8T5l372jrzO5cMPX5gjtkA6SWMdZ8/hc7iwXjM9OKLsivkniYBOi3yvX+Q+73 fUzd/2z/WiXzKTvguEljdow18/w/izPq1chtoIarwRGh+mc1/cvGxn5S0oOMbLWxP21T bYKIjt3tEH+INwPx2rEcp5sjzLGqC4o49+UELy/96ZNZypbGsOVDVhsXoGQkkNsGgvHK q4ZFfiZObh+F9yfZ91DUFzwRKEFQOJK2uB19dMogA5z6eO7HlVGBDPnhJ/F/SlsejZxm E/MYDOaNxfTCHc37qKOTo2aTl45Rqi6dE7vmffhPcIZxg0TeDdfGJaz9LBH6NUmMysUe ExXw== X-Forwarded-Encrypted: i=1; AJvYcCXaRlH8UVbJWjsjhipmPYunW62CBDsOCZlfg/gB9kIxDO0hT4eJyNPI45z0kT0oW0u/kvKanEao9MWcXvGGl6fY1gY= X-Gm-Message-State: AOJu0Yzw9d7ZPMxfGYowdCbbrs11d9ANHb2pCtXsW9tP824NJy+MKCfE euOmDS3PR0sZ334xk5V3I1e9uGhC8AhxVsYZw+/aulRHLZ+2+5De X-Google-Smtp-Source: AGHT+IH69WvgxiMD6OMwiWg1G+NoqJLzclvrJI/UH51QjspTKcbBFBgby0YTMR1Hy0MUj/xO2uBgjQ== X-Received: by 2002:a17:907:9718:b0:a77:e48d:bc8 with SMTP id a640c23a62f3a-a7ac4f0bfcamr93989666b.21.1721871725006; Wed, 24 Jul 2024 18:42:05 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acad41462sm17069466b.119.2024.07.24.18.42.03 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Jul 2024 18:42:04 -0700 (PDT) From: Wei Yang To: rppt@kernel.org, richard.weiyang@gmail.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 3/5] memblock test: fix implicit declaration of function 'memparse' Date: Thu, 25 Jul 2024 01:41:55 +0000 Message-Id: <20240725014157.17707-3-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240725014157.17707-1-richard.weiyang@gmail.com> References: <20240725014157.17707-1-richard.weiyang@gmail.com> X-Stat-Signature: 4g8nu1xgx3zgd67gaen95sbp7qqyojtt X-Rspamd-Queue-Id: 634501A001C X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1721871726-329663 X-HE-Meta: U2FsdGVkX1+co/gFiyqB2+QhszK9emMqW1atgrlVCjQuqqahAyYPFTF+3JGUfB5DvWiaLdyqiTxz07i+7aZBbyfXBB0ZGRNuLatTqAkVMOJYac84z/raLV+976iJALU7M+O6AJ8VbvldYvxxro8MDFSplbmv48kQd5sTHP4NRH7dPQaF1yCtX2X6ZNSKu7CtnQJr6KtJl2wAkDKb35TA20T0DMi/EISo16k9DD501tbbDq8fYxY7jgVvl0hGO7bnAaa/+nhksdZcZxPbxP7TJAuOm4PQ6d8cvDMqbEzCg5L9ZKpeXfl/kUYNl8YAFcZlFoM2GeZML/jEEY23++3mihGFydWiNSHEnZoCiDCZLZ551zIXKZSgJpqdA8nU+zg/G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owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Commit 1e4c64b71c9b ("mm/memblock: Add "reserve_mem" to reserved named memory at boot up") introduce the usage of memparse(), which is not defined in memblock test. Add the definition and link it to fix the build. Signed-off-by: Wei Yang --- tools/include/linux/string.h | 1 + tools/lib/cmdline.c | 53 +++++++++++++++++++++++++++ tools/testing/memblock/Makefile | 2 +- tools/testing/memblock/linux/kernel.h | 1 + 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 tools/lib/cmdline.c diff --git a/tools/include/linux/string.h b/tools/include/linux/string.h index db5c99318c79..fb8eda3019b5 100644 --- a/tools/include/linux/string.h +++ b/tools/include/linux/string.h @@ -47,4 +47,5 @@ extern char * __must_check skip_spaces(const char *); extern char *strim(char *); extern void *memchr_inv(const void *start, int c, size_t bytes); +extern unsigned long long memparse(const char *ptr, char **retptr); #endif /* _TOOLS_LINUX_STRING_H_ */ diff --git a/tools/lib/cmdline.c b/tools/lib/cmdline.c new file mode 100644 index 000000000000..c85f00f43c5e --- /dev/null +++ b/tools/lib/cmdline.c @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * From lib/cmdline.c + */ +#include + +#if __has_attribute(__fallthrough__) +# define fallthrough __attribute__((__fallthrough__)) +#else +# define fallthrough do {} while (0) /* fallthrough */ +#endif + +unsigned long long memparse(const char *ptr, char **retptr) +{ + char *endptr; /* local pointer to end of parsed string */ + + unsigned long long ret = strtoll(ptr, &endptr, 0); + + switch (*endptr) { + case 'E': + case 'e': + ret <<= 10; + fallthrough; + case 'P': + case 'p': + ret <<= 10; + fallthrough; + case 'T': + case 't': + ret <<= 10; + fallthrough; + case 'G': + case 'g': + ret <<= 10; + fallthrough; + case 'M': + case 'm': + ret <<= 10; + fallthrough; + case 'K': + case 'k': + ret <<= 10; + endptr++; + fallthrough; + default: + break; + } + + if (retptr) + *retptr = endptr; + + return ret; +} diff --git a/tools/testing/memblock/Makefile b/tools/testing/memblock/Makefile index 7a1ca694a982..d80982ccdc20 100644 --- a/tools/testing/memblock/Makefile +++ b/tools/testing/memblock/Makefile @@ -8,7 +8,7 @@ LDFLAGS += -fsanitize=address -fsanitize=undefined TARGETS = main TEST_OFILES = tests/alloc_nid_api.o tests/alloc_helpers_api.o tests/alloc_api.o \ tests/basic_api.o tests/common.o tests/alloc_exact_nid_api.o -DEP_OFILES = memblock.o lib/slab.o mmzone.o slab.o +DEP_OFILES = memblock.o lib/slab.o mmzone.o slab.o cmdline.o OFILES = main.o $(DEP_OFILES) $(TEST_OFILES) EXTR_SRC = ../../../mm/memblock.c diff --git a/tools/testing/memblock/linux/kernel.h b/tools/testing/memblock/linux/kernel.h index ca56f36ef296..67c9ea1428a5 100644 --- a/tools/testing/memblock/linux/kernel.h +++ b/tools/testing/memblock/linux/kernel.h @@ -8,6 +8,7 @@ #include #include #include +#include #define virt_to_phys(p) ((unsigned long)p)