From mboxrd@z Thu Jan 1 00:00:00 1970 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 7F5DBC43334 for ; Fri, 1 Jul 2022 01:50:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B9D7F6B0071; Thu, 30 Jun 2022 21:50:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B4E626B0073; Thu, 30 Jun 2022 21:50:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A14B26B0074; Thu, 30 Jun 2022 21:50:43 -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 9224C6B0071 for ; Thu, 30 Jun 2022 21:50:43 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1E91C3AE for ; Fri, 1 Jul 2022 01:50:43 +0000 (UTC) X-FDA: 79636851966.03.6F662FA Received: from mail-oi1-f196.google.com (mail-oi1-f196.google.com [209.85.167.196]) by imf19.hostedemail.com (Postfix) with ESMTP id AA3351A000D for ; Fri, 1 Jul 2022 01:50:42 +0000 (UTC) Received: by mail-oi1-f196.google.com with SMTP id s188so1473512oib.6 for ; Thu, 30 Jun 2022 18:50:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=BPm5UBqQEkho6a63OI9gXhUvNp389zpCyk7F/wC2i0Y=; b=HOr2ycPAp0RwGOvIdF7yC/CI8FD6VYKm1P+G48K/m17MRB3JoqrQKy8kO1CFUH7ob3 EKUn9waC3uxNm6BdnZesXlFFCOnaCTfsFi8QgoBx6xZV3KwgWzjo0CrmxSOXzXEiA81H 6kUsA8NaALTh28FdZAyuMpvIjfXst1gMAVbgd/Ztv9yljo06T1w6hkp9xB5OvDxFUMjR R15fQl1ayAowPddTv1cntOwEtJq2r4H/G3vZjZ9qK7VC0lpyj9wEIR5O/kof4KpRBZ4c F68LTuwb9WoB/qqxwpqiVI/V8f9pv5g7+b2Fr+FWdrZSpzYpni/kwbyfCbxvnn9+0qGY bmUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=BPm5UBqQEkho6a63OI9gXhUvNp389zpCyk7F/wC2i0Y=; b=hOADwhAJzxiKtAYCfXpaL/a2+KY4D8nDGeLgRbiOcaEF6/fUoLU9jUJG4h8/F/NF+m 6r7Gs3VxFYkjdxYsueIA1MslGYPPPqZhVzgDOR+32zSmMHkyXtBlRrvZ0saAh7oN/hNA HFW0NaHYMU489HhWjnGBRMQyYL0rUxX4GU8xQEdyOXPP6vE6q487Iy0G8DU6IpU3ML9V QBs9lOhrvfhgJxszQXP9ORyjvMzknlybSq3dGLpkmSwe+j7FcEQEPeESdtdmmO+Xx7iZ /DdCgLyg1nmynHwccBNQQ78cwQhu2Y/MatHtPZS/g2WsoKWCQFO9zaSDN+KtbYxgOT7q +jqA== X-Gm-Message-State: AJIora8pjZQofHiwHfbtnFGrsz6J0NCvjB+2GOG8poPlD9mSTIbO87pt ToHxXNcn93/OKzOZanZsyz0= X-Google-Smtp-Source: AGRyM1vLVmWCgu4SwIBw+H0gwtB6cTs3qYQaHuCZSjNS0AKD8ZlG1JTgBOZSwIxcQC2PeLDT84KKgQ== X-Received: by 2002:a05:6808:1794:b0:335:a89f:55b8 with SMTP id bg20-20020a056808179400b00335a89f55b8mr7300425oib.261.1656640241214; Thu, 30 Jun 2022 18:50:41 -0700 (PDT) Received: from bertie (072-190-140-117.res.spectrum.com. [72.190.140.117]) by smtp.gmail.com with ESMTPSA id a28-20020a0568301ddc00b00616b06d520dsm10709158otj.5.2022.06.30.18.50.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 18:50:40 -0700 (PDT) Date: Thu, 30 Jun 2022 20:50:37 -0500 From: Rebecca Mckeever To: David Hildenbrand Cc: Mike Rapoport , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 2/4] memblock tests: add verbose output to memblock tests Message-ID: References: <883c28e34527fd4cdc55df97c791ed8b2e79538d.1656368930.git.remckee0@gmail.com> <5db2944e-9d64-8faa-83d3-fd02fce583bd@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656640242; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=BPm5UBqQEkho6a63OI9gXhUvNp389zpCyk7F/wC2i0Y=; b=Qq/UDjP307/rUd2HribOszc4NPa1JhIjacRI/bW9dOq30PzkCJ0qYc2lDfGCIO5rLGlNAx ovWw58hj4rANP9NzcEhIsc/KusDXRt0ZgjIiWsYiLFsPzFoeEpJosBmdPPNMV/76ks4OXy sQOr2EgIVk4NoWj1HcVY8xGjB172Ui4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656640242; a=rsa-sha256; cv=none; b=3SNFHhcMztMj/JNnOuAyUvHgslP9Pr7fop1KqsSt565KGqsS8qbIrFeTfqA8D8EltYNJet eh0ksMqPG0JIXZqFQo0I0D6DiP4MjICulDnNMSbsSrWdk+P7yRypVEd3vfoKxhtGMcdw4q HGFkRlerpFU9MUuYCcJ5mMr4aBp/iVs= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=HOr2ycPA; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf19.hostedemail.com: domain of remckee0@gmail.com designates 209.85.167.196 as permitted sender) smtp.mailfrom=remckee0@gmail.com Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=HOr2ycPA; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf19.hostedemail.com: domain of remckee0@gmail.com designates 209.85.167.196 as permitted sender) smtp.mailfrom=remckee0@gmail.com X-Rspamd-Server: rspam03 X-Rspam-User: X-Stat-Signature: d6h6y45k34wu7hw79pwqqqcd55rqhm8e X-Rspamd-Queue-Id: AA3351A000D X-HE-Tag: 1656640242-756837 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000155, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Jun 30, 2022 at 12:17:48PM +0200, David Hildenbrand wrote: > On 29.06.22 19:07, Rebecca Mckeever wrote: > > On Wed, Jun 29, 2022 at 01:34:54PM +0200, David Hildenbrand wrote: > >> On 28.06.22 00:34, Rebecca Mckeever wrote: > >>> Add and use functions and macros for printing verbose testing output. > >>> > >>> If the Memblock simulator was compiled with VERBOSE=1: > >>> - prefix_push(): appends the given string to a prefix string that will be > >>> printed in test_fail() and test_pass*(). > >>> > >>> - prefix_pop(): removes the last prefix from the prefix string. > >>> > >>> - prefix_reset(): clears the prefix string. > >>> > >>> - test_fail(): prints a message after a test fails containing the test > >>> number of the failing test and the prefix. > >>> > >>> - test_pass(): prints a message after a test passes containing its test > >>> number and the prefix. > >>> > >>> - test_print(): prints the given formatted output string. > >>> > >>> - test_pass_pop(): runs test_pass() followed by prefix_pop(). > >>> > >>> - PREFIX_PUSH(): runs prefix_push(__func__). > >>> > >>> If the Memblock simulator was not compiled with VERBOSE=1, these > >>> functions/macros do nothing. > >>> > >>> Add the assert wrapper macros ASSERT_EQ(), ASSERT_NE(), and ASSERT_LT(). > >>> If the assert condition fails, these macros call test_fail() before > >>> executing assert(). > >>> > >>> Signed-off-by: Rebecca Mckeever > >> > >> > >> [...] > >> > >>> > >>> diff --git a/tools/testing/memblock/tests/common.c b/tools/testing/memblock/tests/common.c > >>> index 62d3191f7c9a..e55b2a8bf0ff 100644 > >>> --- a/tools/testing/memblock/tests/common.c > >>> +++ b/tools/testing/memblock/tests/common.c > >>> @@ -4,8 +4,12 @@ > >>> > >>> #define INIT_MEMBLOCK_REGIONS 128 > >>> #define INIT_MEMBLOCK_RESERVED_REGIONS INIT_MEMBLOCK_REGIONS > >>> +#define PREFIXES_LEN_MAX 256 > >>> +#define DELIM ": " > >>> +#define DELIM_LEN strlen(DELIM) > >> > >> Why not simply > >> > >> #define PREFIXES_MAX 15 > >> static const char * __maybe_unused prefixes[PREFIXES_MAX]; > >> static int nr_prefixes; > >> > >> And then simply insert/clear the corresponding prefixes[] pointer and > >> update nr_prefixes? > >> > >> When printing, you only have to walk prefixes from 0 ... nr_prefixes - 1 > >> and print the values. > >> > >> Avoids any string modifications. > >> > > What is nr_prefixes? Number of prefixes? Currently, the longest prefix is > > 49 characters (alloc_try_nid_bottom_up_reserved_with_space_check), so I > > think PREFIXES_MAX would need to be at least 52 (including the delimiter), > > but let me know if I'm misunderstanding. > > nr_prefixes would be the current number of prefixes (not the length). > > You be storing pointers to strings in the constant pool, not copying the > strings over. > Okay, that makes sense. Good idea! I'll make this change. > -- > Thanks, > > David / dhildenb > Thanks, Rebecca