From patchwork Tue Aug 6 01:03:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13754295 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 39B18C3DA7F for ; Tue, 6 Aug 2024 01:03:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 445346B0085; Mon, 5 Aug 2024 21:03:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 357046B0088; Mon, 5 Aug 2024 21:03:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B6046B0089; Mon, 5 Aug 2024 21:03:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E4DFA6B0085 for ; Mon, 5 Aug 2024 21:03:37 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9E11F12088D for ; Tue, 6 Aug 2024 01:03:37 +0000 (UTC) X-FDA: 82420022874.20.80552FE Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) by imf07.hostedemail.com (Postfix) with ESMTP id D824640002 for ; Tue, 6 Aug 2024 01:03:35 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=SrIRv6xy; spf=pass (imf07.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.49 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=1722906167; 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=CmGbALZpVE74Pa5Rw5VvSTllmCd7Qc+k5GQGREaFuVRiI82Y0kqsEzXXrYCeWDkSl2Kb7b E+tITFTYeQiLDyJ5UJGzbQXglGlCKOhJIKuJ9mm4QvcdqHeF1Gxl59oEs3Pry9Q6a6Wn0W kxDRnO1ta3racxIAAWIj9XEsNorVXDM= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=SrIRv6xy; spf=pass (imf07.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.49 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722906167; a=rsa-sha256; cv=none; b=NDW0Zf9buiF8Df4fRTXK0niFqWhl37/+JyLHQdWkQOvO7O6DdMomPeHGhe6GqorUV6YWSG MaUbR9N+QZMS9ABzuxhHD4l3hwzyWaLm5f9duW8gHfD2JNd3ef/2ETvubtE/W7UQoA8imd rl3EMUltge2nRhli2a9UpNDs1k1564w= Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a7a94478a4eso1025422166b.1 for ; Mon, 05 Aug 2024 18:03:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722906214; x=1723511014; 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=SrIRv6xyTYDmtOhJDypwpv9sMFGshkN2LZmL0Zk4oKeVqIdKrXANmjB3hgUMyHyo4U Vkuhb4lJ5u6ZanJS8pfWQkeCqJf7i2WP1FDMreLrgKLZMYjW063yB1J17x+DDRRkxPFU WqE5W6tmwoEi4xfissOliYz4DT3uw2fKViUacKNpi8VjMNz7eB7M+OtZhzOVllfXr6KF RZs7NRpGxY3CGOE5Ok+LY7vXst2L8USsP+UMf0WNV9PaZbI6aVQ18ImyWF4n9MFkxDg6 6b9m216ALcj0ocJGRL2YTMLYQCUXg/gZzfefaHyRiUFWzpK/Yco7u4LwSGagMPaqCf6/ Z8nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722906214; x=1723511014; 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=SXfAv5fkji5PY5S2wfCH1kLQMA3OLj85gzrW0fm4Zs/oiBjfq+mg/oDN8bMAHJR95O M5mL4/9BPA4V/j7t5v03esITKcHDUkKzV57OWBbuaetYJORtTpeVyM9DmzX6rPXV4Wqm FpCwCyKevj6VEcTlRDjiE4HyimGBx3uzqQM/YobASvYZlCaz2lKLQnPH4YYZjFN5CX7k VrHYaOyQOQOitXeQAHHcUMICF+3oaXYO5GFEB9YeHNWKPfFdN4c+75sZPca8iqmoNITA pyWmcr/1DoaT1uaprybYginXxtlqXjqYj9hGk+5S6pn+SF59escOphuxh7OPZgKc+guU znQA== X-Forwarded-Encrypted: i=1; AJvYcCWTdeqNGQJeai3OvnJv4QUzs9OIumWoDuz9hH0zOGCoBbNqT77/S/XCpHNuBhucYsWTzkXr9u4u3HJNa8Esj2QVzgA= X-Gm-Message-State: AOJu0YzNF3X4rPLqWfgn/z5uaQeClUVOjmC9i+j4lnmd8uC5/11JtLmL OAhrsktgKl0399JPuy2auByx3Y/AonCZdSJdrC66UJjLHthcoh2m X-Google-Smtp-Source: AGHT+IHqAXbyPKmlhIkOspU9uqm8KIkjo9T7iVX7QCIWp5S/2DklXoQj3Aa3giIsvCG/CqJlwiGi9w== X-Received: by 2002:a17:907:6d12:b0:a7a:8a38:9d99 with SMTP id a640c23a62f3a-a7dc628ea90mr901339766b.35.1722906214345; Mon, 05 Aug 2024 18:03:34 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7dc9e7fe2fsm504877666b.178.2024.08.05.18.03.33 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Aug 2024 18:03:33 -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 v4 3/5] memblock test: fix implicit declaration of function 'memparse' Date: Tue, 6 Aug 2024 01:03:17 +0000 Message-Id: <20240806010319.29194-3-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240806010319.29194-1-richard.weiyang@gmail.com> References: <20240806010319.29194-1-richard.weiyang@gmail.com> X-Stat-Signature: bepyftu7jgh3iz3b69sgehdy8y8db14d X-Rspam-User: X-Rspamd-Queue-Id: D824640002 X-Rspamd-Server: rspam02 X-HE-Tag: 1722906215-204401 X-HE-Meta: U2FsdGVkX18UzF4ExzGN11hKhTPrJVh9SgRxKsXVBAaodnsmLJGSk2TXX8AL5kNmbHcwxCj3tAXpts2Om7uVbjVMtSVZiM++r7WXHoncpVRfvXWFlwmfIcnS0PYQmQkp3Xp/SDLB+Ct8nCZLITSouqk+98bbUm/VW9AE5cg5XZ0mJoxilW2dv0XKWWiXY77ZXzA4g1XdiS2KMWpCp48k1VlidFf6mLZiWtXZNaQYVb70Zv622LF02RZZHzW0+DCvIovdas8e4+C0mP39SPW2htvcF9Gh7Wt3aR7iAOUONc4upVp4GtSr3NmTRpyX+UCHrV+RMd1nPGwpvP9eC2ClM9qxt6kcy+A6SGmwgiD4YA5M5ibtVsLrI6stRgac3SrkRfIVEOMY0L6Dg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vack.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