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 57DABC004D4 for ; Thu, 19 Jan 2023 12:58:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BADD36B0074; Thu, 19 Jan 2023 07:58:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B5D3E6B0075; Thu, 19 Jan 2023 07:58:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9FE456B0078; Thu, 19 Jan 2023 07:58:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 91B516B0074 for ; Thu, 19 Jan 2023 07:58:48 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 28BDD14013F for ; Thu, 19 Jan 2023 12:58:48 +0000 (UTC) X-FDA: 80371553136.17.8D7CE5A Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf19.hostedemail.com (Postfix) with ESMTP id 5501C1A0010 for ; Thu, 19 Jan 2023 12:58:45 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=hf8lOQ9q; spf=pass (imf19.hostedemail.com: domain of rppt@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674133125; 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=LCdhqiT1nKSATIIDcekNLDy0wYOyDKUxJXKs3d/V5Og=; b=PpDdUQJ2xDkpEZ2bAbQriD2Ab83omjqOGQbaFK3xTILWQ5HGmBd3ALngLMZ1BF2dGm7XBh UlLw710AQwokNwY0eFrn7pcxlcXU8hsJChiTUP2rcX7+3gWslOoZb3b8rHxwugDY8b7tvs +QYLNs3eTATbV68S9QungKnqGrSN3kg= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=hf8lOQ9q; spf=pass (imf19.hostedemail.com: domain of rppt@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674133125; a=rsa-sha256; cv=none; b=O5ouTblW1P3ycaPFD6KJ6YlaclDuqwoOg2QBHw/gJ6/ousNYk8Y8o4KbRVFTU+BXi8Uxu6 Cvbii7K8QtwmByDFal0xzzhgeJ46u3UwQ/NzQeYuvrksBcWNoxWjW+HfvR3DGq+QJmH7oT +zlb8glgPnq3WtEEFFcnnzAJhvCYBd4= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C5B2AB82117; Thu, 19 Jan 2023 12:58:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63145C433F1; Thu, 19 Jan 2023 12:58:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674133122; bh=O7Q6zdiSVpb/QDVMFg0WjTXi5Io4YYx9Rx3NmusYSWo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hf8lOQ9q6jbPYH6nwpaVSCKgXIockgfW0UvyhxN2AEaCZ+GoMbcxxyZvsiR4ls/bm xSeTiu5YAbbHejfxRtz96g3kGRLEetjE2ZbcIAsS19nmXb7NvMVy4LtIWnLzoD1wA5 eB8qS9YdFTqD88eGY/4JhIBOmTS3odZvsbS7WuPKK2HNHxJBeJd7cDad2iUqVCb/lF Faqaz6JrSdkshCch9vkc+5BYBxCdfpn4LzyBl3M4D1FtOUrRajX+dNNw7FZ5mG9utT eynXauAKI484b9aNgpzuYRzgQGHd2U7ulQWrxiDwTEkU/fnnGZ/PKVGBVSUv2vXe62 TD5wNcSN7ZoCw== Date: Thu, 19 Jan 2023 14:58:29 +0200 From: Mike Rapoport To: Claudio Migliorelli Cc: Rebecca Mckeever , David Hildenbrand , Shaoqin Huang , Karolina Drobnik , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Add tests for memblock_alloc_node() Message-ID: References: <0c3fdce6-3180-89c6-ba9e-77b7e98a5691@mail.polimi.it> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0c3fdce6-3180-89c6-ba9e-77b7e98a5691@mail.polimi.it> X-Stat-Signature: iwqmtnf3cjap7d9xp898bwkgitgkdpjc X-Rspam-User: X-Rspamd-Queue-Id: 5501C1A0010 X-Rspamd-Server: rspam06 X-HE-Tag: 1674133125-427719 X-HE-Meta: U2FsdGVkX1/3yVkFFb1qdlkyAR3BmnoA7ZzehRz2rRzrZSV1noxEV+yp17AtxVeCWmgAaBohYjd1Grx0gVMBlvauQcOl2HQnhzVLUxl+zWV8RP90qNkE4CfmRDWnU3GopqM+8NElx4PP15g3bWHW29Ryd0ESNcoUTNJIsmdnZ/LiFK/pne63tiMbLEQ3Tby+Kwnafi0M4TpTxoa1gYkhywTMQrtkJoLPZpBzDm3QhFaVKQTEIIePHkM0DPgErUMJD3ubkxmQldxqJnutQSXTjr46Iz0GmtdgglNoKOcxDliZa8+oUTmFvRQwsjDySAXlv1LLnkoPLn5Sasl4Z5SIEhTPAIBenvFeWkvEe0i9AvUfCiPpe+CQyStifELMpY8++im517bNqcF1O1MDXi/QYKfLxi7PROZZuxBQo2oEMWp6F/4c2VyoHEk72a3fJR9CS/b2qobrG2R5L93hRTJL+4Qwkgq+LYuzKUhScHwXGLqsg4S6uuhBFP4wi3jpGVOs/iK95UqqF3/qHWDQJP5X2kcx1UwenyjgWkUA9+2Cmn0No3hjD/nQ0x31lxEZzEFx8cHorxGT0V2uld7bZ3sVwym4TDktDHECbZA5/kYnoQBuJV3ydqcffZ5S6GCViurTHJOaj6G3GSsuuiysLB3teWzBVOs89Yajv4S17fz3oRr+fkD5TnO+DP71VxMpcUYX2fEo+LDkdtgUvGVCLHl2NzaOmbUZPeuzXUixgDZaB1fZk0g7dm9cIT3QZpcoIsGM+6dIbxekWkUx3NLjM4ICURXdZuMNvDNhYJrKYrI5IdQZhH4HJkWqpXipUzUfAizctRTpIntNnbhGXifbOfnKczQpSdGS3CbKtKOvhUvy4AFbGtR0HlJ+FFPZgquAfiDQo1itw+jW+GmmUd6nkYd9RzydrhTlO1fvyFgOb+x0xVTzNu9LrAp54DwtPigEaGZiv5WbAcbob4rNvodFgdA flaTGpvp nYTEmLxcelK8s5BKZiQaRVY36shGVGxq35xluK6E/zNb239TMeyokcuuBwPamf8VhqAUFC6EZehxsJFE= 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 Fri, Jan 13, 2023 at 05:01:43PM +0100, Claudio Migliorelli wrote: > These tests are aimed at verifying the memblock_alloc_node() to work as expected, so setting the > correct NUMA node for the new allocated region. The memblock_alloc_node() is mimicked by executing > the already implemented test function run_memblock_alloc_try_nid() and by setting the flags used > internally by the memblock_alloc_node(). The core check is between the requested NUMA node and the > `nid` field inside the memblock_region structure. These two are supposed to be equal in order for > the test to succeed. We already have tests that verify that verify that NUMA APIs respect nid parameter, e.g. alloc_nid_numa_simple_check(). If you'd like to add a test that verifies that memblock_alloc_node() works as expected, don't mimic it, but use it directly. When posting patches please format the commit log to wrap at 75 columns (see Documentation/process/submitting-patches.rst) and use recent Linus' tree as the base. > Signed-off-by: Claudio Migliorelli > --- > tools/testing/memblock/tests/alloc_nid_api.c | 43 ++++++++++++++++++++ > 1 file changed, 43 insertions(+) > > diff --git a/tools/testing/memblock/tests/alloc_nid_api.c b/tools/testing/memblock/tests/alloc_nid_api.c > index 2c2d60f4e3e3..9183e2219c5c 100644 > --- a/tools/testing/memblock/tests/alloc_nid_api.c > +++ b/tools/testing/memblock/tests/alloc_nid_api.c > @@ -2483,6 +2483,40 @@ static int alloc_try_nid_numa_split_all_reserved_generic_check(void) > return 0; > } > > +/* > + * A test that tries to allocate a memory region through the > + * memblock_alloc_node() on a NUMA node with id `nid`. The call to the > + * memblock_alloc_node() is mimicked using the run_memblock_alloc_try_nid() > + * with appropriate flags, the same used internally by the memblock_alloc_node(). > + * Expected to have the correct NUMA node set for the new region. > + */ > +static int alloc_node_on_correct_nid_simple_check(void) > +{ > + int nid_req = 2; > + void *allocated_ptr = NULL; > +#ifdef CONFIG_NUMA > + struct memblock_region *req_node = &memblock.memory.regions[nid_req]; > +#endif > + phys_addr_t size = SZ_512; > + > + PREFIX_PUSH(); > + setup_numa_memblock(node_fractions); > + > + allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES, > + MEMBLOCK_LOW_LIMIT, MEMBLOCK_ALLOC_ACCESSIBLE, > + nid_req); > + > + ASSERT_NE(allocated_ptr, NULL); > + assert_mem_content(allocated_ptr, size, alloc_nid_test_flags); > +#ifdef CONFIG_NUMA > + ASSERT_EQ(nid_req, req_node->nid); > +#endif > + > + test_pass_pop(); > + > + return 0; > +} > + > /* Test case wrappers for NUMA tests */ > static int alloc_try_nid_numa_simple_check(void) > { > @@ -2621,6 +2655,14 @@ static int alloc_try_nid_numa_split_all_reserved_check(void) > return 0; > } > > +static int alloc_try_nid_numa_correct_node_simple_check(void) > +{ > + test_print("\tRunning %s...\n", __func__); > + alloc_node_on_correct_nid_simple_check(); > + > + return 0; > +} > + > int __memblock_alloc_nid_numa_checks(void) > { > test_print("Running %s NUMA tests...\n", > @@ -2640,6 +2682,7 @@ int __memblock_alloc_nid_numa_checks(void) > alloc_try_nid_numa_large_region_check(); > alloc_try_nid_numa_reserved_full_merge_check(); > alloc_try_nid_numa_split_all_reserved_check(); > + alloc_try_nid_numa_correct_node_simple_check(); > > return 0; > } > -- > 2.39.0 > -- Sincerely yours, Mike.