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 1597BECAAD6 for ; Fri, 26 Aug 2022 09:28:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A281B6B0074; Fri, 26 Aug 2022 05:28:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D6BB6B0075; Fri, 26 Aug 2022 05:28:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 89EDD940007; Fri, 26 Aug 2022 05:28:20 -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 7B9406B0074 for ; Fri, 26 Aug 2022 05:28:20 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 6100A403D5 for ; Fri, 26 Aug 2022 09:28:20 +0000 (UTC) X-FDA: 79841217960.05.754D8BF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 7077F4001F for ; Fri, 26 Aug 2022 09:28:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661506098; 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=tZm8+FPJNVay8zI5ZDreamxl1om7Nr78rlpU7kmodO4=; b=YprC3Xd15b7wQ9mIbbM+EHESfDN1Lv98Tg621Nf2lUHRxQBLKfdglLbWLHI3GPqu3qkTNU WGWLfV+onTCHRRgOzCnJeN9iyihBBWqp1hZqL4cPJ+rq0svpcwKYoyR4NVGSx+gvPcob3G 2rFdBxzef0wlh6K+2KSsUCp955tB57c= 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.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-662-iEMFrIYzMkmtyZO-tLGPOQ-1; Fri, 26 Aug 2022 05:28:12 -0400 X-MC-Unique: iEMFrIYzMkmtyZO-tLGPOQ-1 Received: by mail-wm1-f71.google.com with SMTP id q10-20020a1ce90a000000b003a60123678aso257511wmc.6 for ; Fri, 26 Aug 2022 02:28:12 -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:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc; bh=tZm8+FPJNVay8zI5ZDreamxl1om7Nr78rlpU7kmodO4=; b=JRotLBJWGqtgs7NtkEPoc3K4zntWgbFrMAT2zGOj/B9eJ7tezOCvShtLnMLxiClL/k NwZfxd2Q5zt/xh9gw7JWoctp/ut8B6TRNmqJqfV9/wkzmnyYMOI7KPmWxoz6Slfn3VHf s31D2Z4/AJk89ROz9wHK0/7HEyrqNoTV8vF7iA8W6+v9Vt0pWSkpYATqDDPHWuvCThUq fxErgINWucNy0SgUJ1Y8/I44cG9/c3e3H1PBHzvam6HeoFSntc3x7g0mVf7eZtUqKF7D 8MtXH68G4NjXTK0DxGQJtjEmKZ1l1V3yM01RBPy05pjYqSFxqRDwu0FzHc3U741OLkYs 12Ww== X-Gm-Message-State: ACgBeo27G4BVEdE6DpFJITgBVGrk5ssD8owjEXArPleqC2IXijG6AwK3 cFmcUh6rGcXtLgSfl16kE05fxLibMffuxTJXXwuMFIZ7O9HNWBzvjJDizwg2ezJsbmGSAMBLLa7 uApsXLbkAt/0= X-Received: by 2002:adf:9ccf:0:b0:225:4934:53e3 with SMTP id h15-20020adf9ccf000000b00225493453e3mr4509918wre.210.1661506091103; Fri, 26 Aug 2022 02:28:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR710MOt95gvLSyB2DYQA8RD1oC554oWsCWqEuY3W3PaubYO9NAho/V4h0PHCqjnn7amuZl2oA== X-Received: by 2002:adf:9ccf:0:b0:225:4934:53e3 with SMTP id h15-20020adf9ccf000000b00225493453e3mr4509905wre.210.1661506090767; Fri, 26 Aug 2022 02:28:10 -0700 (PDT) Received: from ?IPV6:2003:cb:c708:f600:abad:360:c840:33fa? (p200300cbc708f600abad0360c84033fa.dip0.t-ipconnect.de. [2003:cb:c708:f600:abad:360:c840:33fa]) by smtp.gmail.com with ESMTPSA id v16-20020a5d6110000000b0021e13efa17esm1403883wrt.70.2022.08.26.02.28.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 26 Aug 2022 02:28:09 -0700 (PDT) Message-ID: <8092cd73-f165-9026-ea6e-076e6a96f206@redhat.com> Date: Fri, 26 Aug 2022 11:28:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH v2 5/8] memblock tests: update alloc_api to test memblock_alloc_raw To: Rebecca Mckeever Cc: Mike Rapoport , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <48cfb01ba417895f28ce7ef9b99d1ce0854bfd5e.1660897732.git.remckee0@gmail.com> <20220825213546.GA13624@sophie> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20220825213546.GA13624@sophie> 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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661506100; 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=tZm8+FPJNVay8zI5ZDreamxl1om7Nr78rlpU7kmodO4=; b=pK25prChgTO5i09Ne+JpfvD9hv2gM7bhV+k7ySVIOjaXmCO0RwlLIJlImZJR6vUD/uUl4g vwhL2iY9swHx7UJg175Ms7DBFvjd7WHd5EBm0UI67dzqlmTS+3nMrAfG5nc86S871oYCBp fmmGPfWX6tbMVn849l1+3hI5zEKvgcE= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YprC3Xd1; spf=pass (imf12.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661506100; a=rsa-sha256; cv=none; b=R3aDFsjINsAak6JYKxpHLk9wLDRimJSMIs1iRIehxE0kRXse2sVNw9fLNdWsTIM53Vgaaa ckT3Hmp6+jwirR7EG0R8b2xziy7soKyPD6mKmyE7LLfSI485UaK2JBVvlubJLkHnLJsLfY L36zujzM6pmDf4hJHViZiHTh56qL3hY= Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YprC3Xd1; spf=pass (imf12.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-Rspam-User: X-Stat-Signature: ub33z5aiq8gzda5fr8w5okkqo1syg1wm X-Rspamd-Queue-Id: 7077F4001F X-Rspamd-Server: rspam03 X-HE-Tag: 1661506099-949680 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 25.08.22 23:35, Rebecca Mckeever wrote: > On Tue, Aug 23, 2022 at 11:49:46AM +0200, David Hildenbrand wrote: >> 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. >> > Do you mean use two #defines instead of the enum? I thought enums were > preferred when defining related constants. I guess we have a wild mixture of raw define, enums and __bitwise + defines nowdays. E.g., take a look at include/linux/rmap.h "typedef int __bitwise rmap_t" and how it's used -- that seems to be the new "best" solution for use in the kernel. Having that said, feel free to just let it be an enum :) -- Thanks, David / dhildenb