From patchwork Fri Aug 2 01:09:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13750996 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 55DDEC3DA4A for ; Fri, 2 Aug 2024 01:09:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 129C36B0085; Thu, 1 Aug 2024 21:09:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DA916B0088; Thu, 1 Aug 2024 21:09:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E20756B0089; Thu, 1 Aug 2024 21:09:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id C77396B0085 for ; Thu, 1 Aug 2024 21:09:39 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7D02C80FA7 for ; Fri, 2 Aug 2024 01:09:39 +0000 (UTC) X-FDA: 82405522878.12.7CC5CDB Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) by imf06.hostedemail.com (Postfix) with ESMTP id 9A9A9180013 for ; Fri, 2 Aug 2024 01:09:37 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=QkCBn39b; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.42 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722560972; a=rsa-sha256; cv=none; b=l3VxuwnbJq6uTWp65lg/krC4HKzTyWU4y8564Fex6Rz7u2IAWdTjaKOixqYRGuFI22NXx/ gNxncoVJUSA4/ykjUfoqjMGSGE6A6fiUyryKRPLvA24WG4lBhexo2zGxgqvTGUI0rMb7Jw IiPTuXDvfBkDuI+TNL/LP7E+NZfXRXM= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=QkCBn39b; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.42 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722560972; 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=qyYOlz2K4LoDSHsLe8705YksXRaxa+aqBd+KCuRDSeI=; b=roDaHJm6FCygFGdtEmNsfq1EpxuVj9DU6cQeeJf9fndWLFLasrzu+vvMONv+p7LrBMiRZV t5jzqJs7FoOBA0t9iIHTcS6Qy7M2SQevoZLOK9c7sS7+THdLrflZvj6Qg9sXouv45yP6Si y1chSRl90d06MyWxl+ZI07DsM0t1THs= Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a7d89bb07e7so493354566b.3 for ; Thu, 01 Aug 2024 18:09:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722560976; x=1723165776; 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=qyYOlz2K4LoDSHsLe8705YksXRaxa+aqBd+KCuRDSeI=; b=QkCBn39beKFVaY36Om8VubrCnm5fCE/ln2QvCDvp1T/PmYjYrmZ9CO+eplfet6PvSj C1URD+dDStLF8OeVPirF0mG4H9sJdA8/Vx+vPKgAJ56A0EetHNMFppujLx9fv/bXYZPX oQR+g4vt3nMyiiw6wKeTa8uFlHUnGTA5DG337xuWcP8o9PoibitApEz5HtkHumJmtOJB Dqa+p1fHVqpnxs2IpYELKopC1/HJzYtNqwxAD3iLyCMaZdTA/quIin3RvX6BpwyHFInB zkweIvC7W3SEIBbqLpk9T5OXQyFIpQjAmCKzI+v2Viq6im1UGSZMH34/XcLQgELPuM5O lQDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722560976; x=1723165776; 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=qyYOlz2K4LoDSHsLe8705YksXRaxa+aqBd+KCuRDSeI=; b=Y7Hb1j9acFJBPdfGBMkxAI3wuLmMAFYilBmAH5ypAlyHTVZmwCqwp4huH8nM6417u8 KN1r6q2+Noyfb3OEPh9oC699zeHO+m7eDnkbdMZkfXY2zhhlB9prKmkqxO+lyigm/dGM alV2k5APwaPQwK5mMLLAZ81idO6j1qgzd0sOi0EtS9BA/kTfzDsC64l+EoDKxVsrjDUb 6v9ykqMA7xQiv7C+6dWgY9BI816tewyCaghMnCBTCkWRjh3+BAzljSO5MAP7EAIfcQpW eKiWlqglg29gUIYVv+EI4mEbVKQgJjI4bKY0NkdDlOAw1hIY6b3N7P9NRqythmJD2368 kUcg== X-Forwarded-Encrypted: i=1; AJvYcCVjKWDl1VBWKtGOxzJPLZKKWgJqwliIwpOknUMS4jY/cvqjs9j1ZPeFP49TDQQqtxI4H6F/cCV+8pJBcZvQP2DCNns= X-Gm-Message-State: AOJu0YydaJEXr93fQl3P6J3x0v9xaWGwZ5SCd5IZVzf6Su3k5KjJXgQC Yl+oTwvOJ1a0gU+/obtB6e9kwa18AtzyNNUi4UzcIJhag89/0GMKeUQIvA== X-Google-Smtp-Source: AGHT+IGfRdSWtp+1onxx+iLVymNrzaKRpWBWPTb0pHFWlRNECurwh/KBXdrhvYQIruR2C0q5uxG1Jw== X-Received: by 2002:a17:906:d542:b0:a7a:8e98:890d with SMTP id a640c23a62f3a-a7dc4e2808emr112728166b.16.1722560975756; Thu, 01 Aug 2024 18:09:35 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7dc9d42615sm37107766b.99.2024.08.01.18.09.35 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Aug 2024 18:09:35 -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 v3 3/5] memblock test: fix implicit declaration of function 'memparse' Date: Fri, 2 Aug 2024 01:09:21 +0000 Message-Id: <20240802010923.15577-3-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240802010923.15577-1-richard.weiyang@gmail.com> References: <20240802010923.15577-1-richard.weiyang@gmail.com> X-Rspam-User: X-Rspamd-Queue-Id: 9A9A9180013 X-Rspamd-Server: rspam01 X-Stat-Signature: oadmnsk83nihq6iwjdqsxjp4fdxfuoar X-HE-Tag: 1722560977-724925 X-HE-Meta: U2FsdGVkX1+2mJNazBtS/tRSV1oxfOWUDyncoeLIAdTD86BmoBFqrDhAMBkEC+e8cmD2Nsnzyy/YhcPfFA4/HJEE2JDPpqlxjvDsoznw64cg3RUHHzLSaiYAhK7GMNmw/UB/WIxIku+tQYWAP9dvuMfTp4C4F+4dkz7zY/cbcgNRZbBzQDgPFgfUur/eRHMfqrnlWm4B9tybjbHwoaQ7bTqKCNRT8Lm2OvTgtaOW3q3fBzERJyx9qDavo/UDpjGouUJ0PEJavTreWzPl3comfic5tuil5gDNF+bION2cuz059UG9UjcuJb3X8sH/xwSZjB5WWYM/LFak1FMsV9ATL8kM36zwEvIGuA3mhS7uSC5Sqp+YkIOyBH0lcFMaBR4/p7Ra6hj9upvlwEgk03exsbC+7dsPySIHT5e2cyToXmZ9SAtl8uYS5vjIgWZiLERX1YdtH843bKCyeFFyHEsqKT9ihR5EMhdEPX3ljNC/4+flOdlyJt9tR2xupXvrgaKssfFmlIwnkRmRpWY9xF7vkthDvaXnhOV+CmeR9B/lVaEwoKjW8sMOoB4N4As4U35SYoPh1YCF0wkoJwwvhDK1EPiNGku5VjVBbqh34iLOnYe6AdDetu9Q0CfwNUbMIrEeZXJ06vmG+VYIqWSyQqV9oDwyau2xYPspPvuf2+0IITsF4SiY2+eatuQy6Nkf5ffiPFdybxFUXDajBPqBE5K4xkuBZKtUUGB+L6HXPAhSLwVsEXia1Hm6fqUphJ1y4hv0DEpumeY+W707Yf3HeiaBK11K4bwrr8P0Yu3UJ6JSYsJKmFt2JtlJ9qtuwJM/776yfUaGpZRsDKRaV+Xfs+Prj/gAcFDGei9+TE40E7eFy6HR5desHO3+wL4ZvwZS9ydKa2kqiSlVcE9RzptDOQAN4WsbeiNx5q9Tpw3pwgDAr2VdNbISYStTny3CgsiBUOeC831av7Z+OW7Aj4emyOc yKOsQJMM HgVpLUkev0l5aW4Q9NBHraLmdpRBibOtDI248PeITJ786jjR+vBc0BNkkxWDgDqMXHrzI5M3lEFPsRtT6+KLjL91YyHJDmtixb7cBCjsNLAitd75+huCsJqxh4gLmDbSK6hejN6YmciW4aR3i32UB6JMVLzIcJKW3hM78sPjO1Wiuk0f8iK7lNN7pKCutGiU9JRYju6MTmiNkGY3evVOAG8g2xJag9GiaYh7w+l2Xxre1b5AEFmk7ZSe/wBvh6UajL9Poyks99OefxmhC97nUDUIuuJQ6is3MPOvu+mnQnL1p/rSZ9e/ZWoVr3uNY3EJVwtkuV8rIGlNiN8if2CP49ZpTI7YmYoa1MthRTUbrLkeFTWIBtdtUjljfOPNn21hCOF0+wVcRoUayxQ9tPC4r7wRjFI/OQHZMBtzR 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: 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 d2f148bd8902..c16d9cd2d1ae 100644 --- a/tools/testing/memblock/linux/kernel.h +++ b/tools/testing/memblock/linux/kernel.h @@ -8,5 +8,6 @@ #include #include #include +#include #endif