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 4E4D0C43334 for ; Thu, 30 Jun 2022 10:17:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7060D6B0072; Thu, 30 Jun 2022 06:17:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B6308E0002; Thu, 30 Jun 2022 06:17:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 57EC88E0001; Thu, 30 Jun 2022 06:17:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4A41F6B0072 for ; Thu, 30 Jun 2022 06:17:54 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 09A5335A03 for ; Thu, 30 Jun 2022 10:17:54 +0000 (UTC) X-FDA: 79634501268.21.3CEC12F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 703D718004A for ; Thu, 30 Jun 2022 10:17:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656584273; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rOCaXt8+HI3g+OU53dq0jNzOP8yzJQrPf6iSdbWrmX0=; b=eFecjuZANsdPWP2t2GW4EOi+vb/VzR0Jmqss/Bnl+nRDUgDueUFN7AL9hztMg7s/VSXxHV uWEwmJSlx2aabi7utQjYpMPu0gwgeUSI6uocDkMC+KX0QC9kcWTz3lvYnkoC7AnPbrrhZR uBv25OPd+5VggAoAaLFueLQvkyr1x28= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-318-wsPN3WgSPpWPBs724yC25Q-1; Thu, 30 Jun 2022 06:17:51 -0400 X-MC-Unique: wsPN3WgSPpWPBs724yC25Q-1 Received: by mail-wm1-f71.google.com with SMTP id c185-20020a1c35c2000000b0039db3e56c39so1195013wma.5 for ; Thu, 30 Jun 2022 03:17:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=rOCaXt8+HI3g+OU53dq0jNzOP8yzJQrPf6iSdbWrmX0=; b=iq1RC02pUH6sXY3jIqUbJXMrIPS6A7s3g7nQhApidGVhjeEJz/UsT8wTO6ui2rqDEa UEikfA9kxuquWAV62mpsbUMbGrBIMTuCEJ2qSLEvTPmLjb6JY/wvuHzX870L5zPxeubc ZqB1fG5kn7bEVFuFsjPpcLJohuCNINae/Y221OnMxAly+wNY2d7hIdJVJwZdsMF2smNM 0SjPupN9SEcMoOqwDBGtU6Y5qx/4DDVvWLID3lldGl5TPn2CnI047d1cqvuXA6UmRwrG WQR/TSyJ7eIrO9pbIxUDVQSbg48NxRutHDNIqjqkMrlOnlN6HCmrYBFWvur+nlPrkato h2BQ== X-Gm-Message-State: AJIora/9yj4Wku2VJ3SnabG/rD1tDfAplZaVPf7EUh40+j+7ewUWlEeT QUYH4A6qu6Rb4R8tLsZ4uarKSy05LkKmu03oMWHPOPFPi+40SloGy+21LvfW1p8gefUyGIIB8BP csDWs2dEw2gk= X-Received: by 2002:a5d:614e:0:b0:21b:9736:736f with SMTP id y14-20020a5d614e000000b0021b9736736fmr7440513wrt.200.1656584270288; Thu, 30 Jun 2022 03:17:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sgc41nSJcu5H7wXynnBC8/ogLJm7VRvadyqJgAdRtVWl7h++SF77QONlxdgvS7LCUtRpuoJw== X-Received: by 2002:a5d:614e:0:b0:21b:9736:736f with SMTP id y14-20020a5d614e000000b0021b9736736fmr7440487wrt.200.1656584269979; Thu, 30 Jun 2022 03:17:49 -0700 (PDT) Received: from ?IPV6:2003:cb:c708:7f00:214b:cffb:c693:2b71? (p200300cbc7087f00214bcffbc6932b71.dip0.t-ipconnect.de. [2003:cb:c708:7f00:214b:cffb:c693:2b71]) by smtp.gmail.com with ESMTPSA id t8-20020adfdc08000000b0021350f7b22esm19187608wri.109.2022.06.30.03.17.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Jun 2022 03:17:49 -0700 (PDT) Message-ID: Date: Thu, 30 Jun 2022 12:17:48 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v4 2/4] memblock tests: add verbose output to memblock tests To: Rebecca Mckeever Cc: Mike Rapoport , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <883c28e34527fd4cdc55df97c791ed8b2e79538d.1656368930.git.remckee0@gmail.com> <5db2944e-9d64-8faa-83d3-fd02fce583bd@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eFecjuZA; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf16.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656584273; a=rsa-sha256; cv=none; b=HcZzPipBHBghN3hzCiEj4brFj39PRUmbnQI7HRo7MTWfy0LEnCGNMV4HHxZ1ghKFyvU1E0 zOodfyiQUr8lLbdW+6jRAtU3DswHfPP2b5PmBeLSKIhJ75XF3ZBbveTpbt1QoVk5Axyx9u zzMw/wQKYmp3bCKpLVZl4h2Dz1kuy+k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656584273; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=rOCaXt8+HI3g+OU53dq0jNzOP8yzJQrPf6iSdbWrmX0=; b=AfB1HvAXYs/6mqFHbgfPl+Nwc6bM7YezktJT7Xh23mOrSxOrMEeId3MtyMJUjuJQtDyevB HzBUoKF591qUQJTLVr9X50Wm0c0W4IRmz/8h6RIOmPf4czFbDfecMYA9CY+kLSmgxLvRhK w9+/NPWqnyv0xOd/5JE45Y4Xs3rgVEY= X-Rspam-User: Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eFecjuZA; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf16.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 703D718004A X-Stat-Signature: 1t8jog7ujcsa1ejkfjtfnj8jo8u6utay X-HE-Tag: 1656584273-573649 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: 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. -- Thanks, David / dhildenb