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 50478C32772 for ; Tue, 23 Aug 2022 09:49:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B56A48D0002; Tue, 23 Aug 2022 05:49:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ADE398D0001; Tue, 23 Aug 2022 05:49:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 957DA8D0002; Tue, 23 Aug 2022 05:49:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 7F01A8D0001 for ; Tue, 23 Aug 2022 05:49:51 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4B6E1814DA for ; Tue, 23 Aug 2022 09:49:51 +0000 (UTC) X-FDA: 79830385782.11.FE713B7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf06.hostedemail.com (Postfix) with ESMTP id B4FB6180048 for ; Tue, 23 Aug 2022 09:49:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661248190; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=evJyAqrmQ+PN8lACqVPMdSN0uOt0VMT3OLvez2Taitk=; b=HBB61R1G4brqXOojg35Ua7mbsUALkIQM23ji/4S+0UhFFFqzsZJ3zG//Pnlom/s7ADRqmM 1BQ70lot6Tki/bNQWJIgtBirl6/dez5PEt1XQp69pca5nEUUO4S5rl3oGQUJz4rxh4WnRE scS92sHexJBrYNSZv//efnLbijC/uuc= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-596-Gq7F5RCLNwuuKHJzH2mB4w-1; Tue, 23 Aug 2022 05:49:49 -0400 X-MC-Unique: Gq7F5RCLNwuuKHJzH2mB4w-1 Received: by mail-wm1-f69.google.com with SMTP id q16-20020a1cf310000000b003a626026ed1so2551334wmq.4 for ; Tue, 23 Aug 2022 02:49:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:subject:organization:from :references:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc; bh=evJyAqrmQ+PN8lACqVPMdSN0uOt0VMT3OLvez2Taitk=; b=zoHBrojZOJr3IVHDu6h+9J2e6AKXVsBUputYdu5KqfBZ1puTHVk+PUGfAZ6hAMOTgy ekJ04rInU78+HjNaBzkl5Mqyw9uIQsiPIreoxUWWsqZ+w9XbicwR6vQCqQE+KFHEohnB Bz2j5ExNmtT/7iRlboLLCyj7QlvLPyKVkj78j6jzO/zxMwj6AMR6Q0xysJKNa8TqWA8I oeRWN4dlrJJr5LIuzqVByT+zCIwOjgCYwoM0Wxm3Wh1g95eqiEMJaZHyS3q4MrellpGi rw7162Qo7A+DFXdW6iVEAohZY7mKgLliSji/Yi9T95NqO5yZMJnIbEmoJR/bJGWXr8sD RU7Q== X-Gm-Message-State: ACgBeo1ho1GykOZpW9oQm56KsQPd3jPyLWkoPEDgy+bVYX6MHCq5MRMq 6N1uh9bJNCXAcxLCgEzQmpqAsZyupAQh+bd91lf9Z8+M3oC3Hqe0etZx4aidH7tlfjC9wHNbqfN gIm21fLrahew= X-Received: by 2002:a05:600c:ad4:b0:3a5:50b2:f991 with SMTP id c20-20020a05600c0ad400b003a550b2f991mr1537857wmr.146.1661248188012; Tue, 23 Aug 2022 02:49:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR6NG9jEoNcb22136kmXu7HG2Gru0DTj00CLprYAhQ2al0z3j67ysO2GGC6g9Zt1RN823T9fmg== X-Received: by 2002:a05:600c:ad4:b0:3a5:50b2:f991 with SMTP id c20-20020a05600c0ad400b003a550b2f991mr1537846wmr.146.1661248187647; Tue, 23 Aug 2022 02:49:47 -0700 (PDT) Received: from ?IPV6:2003:cb:c70b:1600:c48b:1fab:a330:5182? (p200300cbc70b1600c48b1faba3305182.dip0.t-ipconnect.de. [2003:cb:c70b:1600:c48b:1fab:a330:5182]) by smtp.gmail.com with ESMTPSA id n189-20020a1ca4c6000000b003a540fef440sm21216152wme.1.2022.08.23.02.49.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Aug 2022 02:49:47 -0700 (PDT) Message-ID: Date: Tue, 23 Aug 2022 11:49:46 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 To: Rebecca Mckeever , Mike Rapoport , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <48cfb01ba417895f28ce7ef9b99d1ce0854bfd5e.1660897732.git.remckee0@gmail.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v2 5/8] memblock tests: update alloc_api to test memblock_alloc_raw In-Reply-To: <48cfb01ba417895f28ce7ef9b99d1ce0854bfd5e.1660897732.git.remckee0@gmail.com> 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661248191; a=rsa-sha256; cv=none; b=jB59YFqtmSgiQ9Vj6IzJbXcIvOGpaU8NR1ZVIe6rZGfoLppRN/6h9IJS+jOyI4ZG1UoLNn 4HOSeq1D8K9snG3CZzpM4L9oMRShYRk6rIvz10MmHiZd8sM2VvZkT/i/gyNIocn6Jnnb43 uvX+vbvDzafZxqMNjeff3uJwdoqDJ+8= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HBB61R1G; spf=pass (imf06.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661248191; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=evJyAqrmQ+PN8lACqVPMdSN0uOt0VMT3OLvez2Taitk=; b=urtaTYf5sBZjrM9IUxhXuujmUNYI7Swmffox5ZKgDoV7ArT9/2Zhjp/MKkowNjZBmu9/L0 ilivxARtEIFlcek1J3I4vRxmGFXxQm7EeNnnON0vOYuE9hYR+HS50HK/AHwTO8Rx6H+AbI 3wmc56lUTYXxA9BjQs6inY7pYPU1fPQ= X-Rspamd-Queue-Id: B4FB6180048 X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HBB61R1G; spf=pass (imf06.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam01 X-Stat-Signature: 6qg8nr8o3xuibfem9s35w189gnb1z1x4 X-HE-Tag: 1661248190-961488 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 19.08.22 10:34, Rebecca Mckeever wrote: > Update memblock_alloc() tests so that they test either memblock_alloc() > or memblock_alloc_raw() depending on the value of alloc_test_flags. Run > through all the existing tests in memblock_alloc_api twice: once for > memblock_alloc() and once for memblock_alloc_raw(). > > When the tests run memblock_alloc(), they test that the entire memory > region is zero. When the tests run memblock_alloc_raw(), they test that > the entire memory region is nonzero. Could add a comment stating that we initialize the content to nonzero in that case, and expect it to remain unchanged (== not zeroed). > > Signed-off-by: Rebecca Mckeever > --- > tools/testing/memblock/tests/alloc_api.c | 98 ++++++++++++++++-------- > tools/testing/memblock/tests/common.h | 25 ++++++ > 2 files changed, 90 insertions(+), 33 deletions(-) > > diff --git a/tools/testing/memblock/tests/alloc_api.c b/tools/testing/memblock/tests/alloc_api.c > index 65bff77dd55b..cf67687ae044 100644 > --- a/tools/testing/memblock/tests/alloc_api.c > +++ b/tools/testing/memblock/tests/alloc_api.c > @@ -1,6 +1,29 @@ > // SPDX-License-Identifier: GPL-2.0-or-later > #include "alloc_api.h" > > +static const char * const func_testing[] = { > + "memblock_alloc", > + "memblock_alloc_raw" > +}; > + > +static int alloc_test_flags = TEST_ZEROED; > + > +static inline const char * const get_func_testing(int flags) > +{ > + if (flags & TEST_RAW) > + return func_testing[1]; > + else > + return func_testing[0]; No need for the else, you can return directly. Can we avoid the func_testing array? Persoally, I consider the "get_func_testing()" name a bit confusing. get_memblock_alloc_name() ? > diff --git a/tools/testing/memblock/tests/common.h b/tools/testing/memblock/tests/common.h > index 58f84bf2c9ae..4fd3534ff955 100644 > --- a/tools/testing/memblock/tests/common.h > +++ b/tools/testing/memblock/tests/common.h > @@ -12,6 +12,11 @@ > > #define MEM_SIZE SZ_16K > > +enum test_flags { > + TEST_ZEROED = 0x0, > + TEST_RAW = 0x1 > +}; I'd have called this enum test_flags { /* No special request. */ TEST_F_NONE = 0x0, /* Perform raw allocations (no zeroing of memory). TEST_F_RAW = 0x1, }; Further, I'd just have use #define for the flags. > + > /** > * ASSERT_EQ(): > * Check the condition > @@ -63,6 +68,18 @@ > } \ > } while (0) > > +/** > + * ASSERT_MEM_NE(): > + * Check that none of the first @_size bytes of @_seen are equal to @_expected. > + * If false, print failed test message (if running with --verbose) and then > + * assert. > + */ > +#define ASSERT_MEM_NE(_seen, _expected, _size) do { \ > + for (int _i = 0; _i < (_size); _i++) { \ > + ASSERT_NE((_seen)[_i], (_expected)); \ > + } \ > +} while (0) > + > #define PREFIX_PUSH() prefix_push(__func__) > > /* > @@ -116,4 +133,12 @@ static inline void run_bottom_up(int (*func)()) > prefix_pop(); > } > > +static inline void verify_mem_content(void *mem, int size, int flags) nit: why use verify here when the other functions "assert". I'd have called this something like "assert_mem_content()" -- Thanks, David / dhildenb