From patchwork Mon Jul 29 01:47:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13744140 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 0EAC0C3DA49 for ; Mon, 29 Jul 2024 01:48:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 110B86B008A; Sun, 28 Jul 2024 21:48:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 09B2F6B008C; Sun, 28 Jul 2024 21:48:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E55F56B0092; Sun, 28 Jul 2024 21:48:03 -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 C142C6B008A for ; Sun, 28 Jul 2024 21:48:03 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 637368018B for ; Mon, 29 Jul 2024 01:48:03 +0000 (UTC) X-FDA: 82391104446.23.53668EA Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by imf17.hostedemail.com (Postfix) with ESMTP id 980204001B for ; Mon, 29 Jul 2024 01:48:01 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Eb4ZHsu2; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.175 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722217638; a=rsa-sha256; cv=none; b=FpG7QTgJFzVyO7+Zu4basqAYNY9uxDLFJUXkk0/uznFjeFkE1gNmrWsaV847q695Hhu5LI XQ0uLINBv1rkm+IiypUDOdUqiL7RjSufVJsXH6k3zAXdfgdhxxyTXD2iguw/DnDs209++z DuBDkx0MCUA95LD+QCoyJH+RivgU7w8= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Eb4ZHsu2; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.175 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=1722217638; 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=8pGYJkIohsvoP/7+vB5/yQLm3V9cz5ivH/12Juk3dPZ6+Lj7VIXjpYRtsfqjduJCDz0enx i6F1+OjyGvDdonA/0qjdnUDifpuZTrBsGo39QqzJrfeg9J+bilszXIziDEQiV+hWOco391 yCREsFfmQ7euQ4c7MeVCO14mcAAq5Dc= Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2ef2c56da6cso34165091fa.1 for ; Sun, 28 Jul 2024 18:48:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722217680; x=1722822480; 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=Eb4ZHsu28Hk3eENISdwOPaMKYvqgMyMhXH049tydTIy+mnB/tdfPwb4fAW7bAIZAyN 28wqadkyS/pM922ZHvCOYJfDXwGzxurCC6+iGNOAOhG1gespcaZMxQStpUjXuyOb5SwB 7DJzbGNd1eJBvH47JYqwLFTkN1fLaxZ7OgtvYgNCt+Sd8arP4bR3S+DITF0d2DgIR0iC dgdzrChdLvUHTXfmEKgSsvJ00cwaua7uJtAKEUv/jNCazbF+0j3owmK/kF3qKApjUEfm yJ6q7pdYGs0iJZzgxt1aVdRFm8bJYEt3OZ0ZrxvjO56xAQPfVz09n9B7fz/qaL1AkRCB 78dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722217680; x=1722822480; 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=ihBBHod1h71uzQCgv12NLi85yp/dDHCLgqop/Ia/BO+yHGDE6GgdAOyMURTOuh2hfX I2i1E3Y+VSvgDfOTvncdYW44jEL3INZvX+yWAa/SzWEGDRljdh4IPHO4QvIXX2yOSlbL vcu2fayPP6FPMr2lXoaS1wCYoAZhV5BlSBe289/GgUFt+NyrIFCKS2/CTtsZ4zRdpwG8 UyadZJi1xwgSuWb3QROmM5krG3qpHFjs1VoiRYV0hFrCUQVzSjAmD7esESKAzUBzpXHe QxRmoaHEJy5MZjl/P/nXjVJjPsTl7TApEDmi/mq6KkOVS96SZEV2t5VeKhpyDvWxDx7J pWgw== X-Forwarded-Encrypted: i=1; AJvYcCXeMqwq1pBI25+XrzDGGzlohTt/d8wFDi6F3ibLbJmhvWB8Fo6F5i20CjIg0x9NXtOHHVUZuU/vz7qFetokUwXOaTM= X-Gm-Message-State: AOJu0YxzXIbUyvB65lzS7Ll+XM1SYDDfMrjQWQc4Bkl2bL3zJbhI9Q67 Q6RbSYZp02+ejsV6PZzkS7ph/V+AX3o3XvbquKywy5dSOdSCvEh5 X-Google-Smtp-Source: AGHT+IE+qlzpCq1UXhhU4cq/cBAQcMXhG/k6viozn73E8gKzNaEC5ly6j9uhxoFrE7HgKYt2maBkxg== X-Received: by 2002:a2e:8686:0:b0:2ef:2a68:beca with SMTP id 38308e7fff4ca-2f12edd8220mr36122661fa.24.1722217679622; Sun, 28 Jul 2024 18:47:59 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ac64eb7c0fsm5053001a12.62.2024.07.28.18.47.58 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 28 Jul 2024 18:47:58 -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 v2 3/5] memblock test: fix implicit declaration of function 'memparse' Date: Mon, 29 Jul 2024 01:47:23 +0000 Message-Id: <20240729014725.29839-3-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240729014725.29839-1-richard.weiyang@gmail.com> References: <20240729014725.29839-1-richard.weiyang@gmail.com> X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 980204001B X-Stat-Signature: 6jx9h6zu8wf5mpc6t4tyeu6k3nbfmxp7 X-Rspam-User: X-HE-Tag: 1722217681-771265 X-HE-Meta: U2FsdGVkX19CqEmS+6NZnPQg8AREDYwq+uVLYXGHK6JamEsLsUvKRfvWmk4zZ4/CrqoYiIDEEAZQ0lBQuAkeYg6L6FWTSb57uDcVC/qDeg1FxP9q8rF9thZtM0Md+tb/OCWqsagqgLZ35SMyHJ+YiNwgs4FIwjAeUF/9z9nKXBMtpezRvu+iXdogW0Za2kq/oiiZ13Z+kwiPAJu1xVqro86EfCfCQX3gesSQkoD6zZ9g1i3ISTL8yK6b4s9YbeTAs0f7qON8YwSauR0gkaa1ED1bHYxkYmK9uj4Pr4fKs6QA/ZXz06en9/pKV9t2RfLd0Cqg7Jbs8WD02aHNYxHjredABh6Rp+zisr/910sTB4bCWLYun+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 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