linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Rebecca Mckeever <remckee0@gmail.com>
Cc: Mike Rapoport <rppt@kernel.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/4] memblock tests: add verbose output to memblock tests
Date: Thu, 30 Jun 2022 12:17:48 +0200	[thread overview]
Message-ID: <ef1620a2-dbc6-911e-5cd0-e860ad7772e0@redhat.com> (raw)
In-Reply-To: <YryG1nuJ+nL9maeS@bertie>

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 <remckee0@gmail.com>
>>
>>
>> [...]
>>
>>>  
>>> 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.

-- 
Thanks,

David / dhildenb



  reply	other threads:[~2022-06-30 10:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-27 22:34 [PATCH v4 0/4] memblock tests: add VERBOSE and MEMBLOCK_DEBUG Makefile options Rebecca Mckeever
2022-06-27 22:34 ` [PATCH v4 1/4] memblock tests: Makefile: add arguments to control verbosity Rebecca Mckeever
2022-06-27 22:34 ` [PATCH v4 2/4] memblock tests: add verbose output to memblock tests Rebecca Mckeever
2022-06-28  1:45   ` Huang, Shaoqin
2022-06-29 11:34   ` David Hildenbrand
2022-06-29 17:07     ` Rebecca Mckeever
2022-06-30 10:17       ` David Hildenbrand [this message]
2022-07-01  1:50         ` Rebecca Mckeever
2022-06-27 22:34 ` [PATCH v4 3/4] memblock tests: set memblock_debug to enable memblock_dbg() messages Rebecca Mckeever
2022-06-27 22:34 ` [PATCH v4 4/4] memblock tests: remove completed TODO items Rebecca Mckeever

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ef1620a2-dbc6-911e-5cd0-e860ad7772e0@redhat.com \
    --to=david@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=remckee0@gmail.com \
    --cc=rppt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).