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 D4BBFC433F5 for ; Wed, 2 Feb 2022 11:03:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E6DFE6B0306; Wed, 2 Feb 2022 06:03:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E1D4F6B0307; Wed, 2 Feb 2022 06:03:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CBE328D00C9; Wed, 2 Feb 2022 06:03:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0092.hostedemail.com [216.40.44.92]) by kanga.kvack.org (Postfix) with ESMTP id BA1F06B0306 for ; Wed, 2 Feb 2022 06:03:43 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 741D618194D4C for ; Wed, 2 Feb 2022 11:03:43 +0000 (UTC) X-FDA: 79097554326.15.2979FD8 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) by imf09.hostedemail.com (Postfix) with ESMTP id 07C6B140008 for ; Wed, 2 Feb 2022 11:03:42 +0000 (UTC) Received: by mail-lf1-f42.google.com with SMTP id f10so13330132lfu.8 for ; Wed, 02 Feb 2022 03:03:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=TjQQYUmGTu4SlGN4+y5JRfYaBvOiJEsY4i+XfsMIVcw=; b=NR+JqdE/LPmTHRaCzKkLVskK7Mfn9RgvVUrEz4zh6NVL4UYMHlKwTSZFTc91ZBrzLg PY/rggu9k3F292VbNNpO7noqwcQQhUWIIajIDzDYPFsCt2jRpOAzT7gqEK4kte5QHAOi XoAziG7b19ZIq1BHo4llxncZzVGn0FITpnJVNLXUNtXf8uG9AHsca330DHLV8ktpIo3y dMIscTsQcsoPBYeZbEo6D0JRHnBJcmMoETVMh9/BGIYA6fNt2n3RuQGtzjjp9l20lHCi LlVc/zhQigswjhhMYrWLVyMSrrAuBEiYOiHwkxN+cIoJmYPSslpb1TSZfhWHCiVYJvEG Vqig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=TjQQYUmGTu4SlGN4+y5JRfYaBvOiJEsY4i+XfsMIVcw=; b=7qosF/wvYij+aodJqjTDOCR+9DTamHhLIfDbeX1ZiqhnKjWw0QZ0Gk5BiQbt/cTBQa o+gHKVFjqXN8JXoDF2NqW8ttbDI77x1Uz/ws60jSBYVGdxMi7UP1xD+0lUO00F7btPzG xscqiEnug7zDwgKCE26MEZ7BwKrNaW0EjG6ifjTvkBytP5mBzzq5Rukt2iIWwhkYvkl/ itJtzG6ZfyOMEfgy/K1EIv0KxMiCHzYAM7WCTwZiEYANyuWMFYo24+kNJ8/ztFNO7FtK WH9n2kjKpOM11ZlNNEZdpRqOXjVHh0GcxfUg1ccrqZLoS5R0uu5edEp5/NGAueHL02wt ONYg== X-Gm-Message-State: AOAM533LbO/bMvvIYo+SGanzlnE0HKzwrdFTNQoo+uwyCD+q/nrJjwhz g6iZTvh1EjX8iLGiRfd6mwI1PxJPp18= X-Google-Smtp-Source: ABdhPJws64T0gA1Iv85NqAl9vCv76PiWwqjP1/FuOAJIlvNPQj191l0flkU6e3cLAeeEfTNMb6Pu6w== X-Received: by 2002:a05:6512:150d:: with SMTP id bq13mr74149lfb.611.1643799821253; Wed, 02 Feb 2022 03:03:41 -0800 (PST) Received: from localhost.localdomain (staticline-31-183-164-222.toya.net.pl. [31.183.164.222]) by smtp.gmail.com with ESMTPSA id r14sm4503937lfr.129.2022.02.02.03.03.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Feb 2022 03:03:40 -0800 (PST) From: Karolina Drobnik To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, rppt@kernel.org, linux-kernel@vger.kernel.org, Karolina Drobnik Subject: [PATCH v2 00/16] Introduce memblock simulator Date: Wed, 2 Feb 2022 12:02:59 +0100 Message-Id: X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Stat-Signature: szuw15k9oeog7jw44wz6ogh566a8rm5i X-Rspam-User: nil Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="NR+JqdE/"; spf=pass (imf09.hostedemail.com: domain of karolinadrobnik@gmail.com designates 209.85.167.42 as permitted sender) smtp.mailfrom=karolinadrobnik@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 07C6B140008 X-HE-Tag: 1643799822-613787 Content-Transfer-Encoding: quoted-printable 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: Memblock is a boot time memory allocator, which allows managing memory regions before the actual memory management is initialized. Because it is used so early during the booting process, testing and debugging it is difficult. As memblock has few kernel dependencies, it is possible to simulate its runtime behaviour in userspace after stubbing a couple of structs and functions. This series of patches adds an initial version of a test suite for memblock, which is a part of tools/testing infrastructure. Checks include= d here test the basic functionality of memblock, which is memory regions management - adding/removing available regions, marking them as reserved or freeing them. To run the tests, build the main target and run it: $ make; ./main A successful run produces no output. Also, It is possible to override different configuration parameters. For example, to simulate enabled NUMA= , use: $ make NUMA=3D1 For the full list of options, see `make help`. The future work will include tests for memory allocation done via memblock_alloc_* and memblock_phys_alloc_* family of functions. It will also focus on improving the test suite by adding dedicated test targets for each group of API functions and verbose output. For a refresher on memblock, see Boot time memory management documentation page[1] and "Getting to know memblock"[2] blog post. Patchset structure: * Patch 1 extracts stub definitions of kmalloc/kfree from the radix-tree testing suite, so they can be used in other tests, including memblock simulator * Patches 2-4 update tools headers to include missing definitions needed by memblock (e.g. phys_addr_t typedef) * Patches 5-9 add new files to tools/include, some with dummy/downsized definitions * Patch 10 adds the basic project with local stubs that are closely connected to memblock * Patch 11 adds a reset function, which is used as a part of the test setup. This functionality is needed, as memblock is reused in each chec= k * Patches 12-16 add basic test cases for the core memblock functionalitie= s [1] - https://www.kernel.org/doc/html/latest/core-api/boot-time-mm.html [2] - https://insecuremode.com/post/2021/12/14/getting-to-know-memblock.h= tml Changes in v2: - Fixed definition ordering in tools/include/linux/gfp.h - Defined atomic_long_t as a struct instead of a typedef - Deleted BIT macro from L1_CACHE_BYTES definition - Removed SPDX information from .gitignore file - Updated Makefile comment on the simulator dependencies - Updated __initconst definition to be an empty macro (full definition is not required) Karolina Drobnik (16): tools: Move gfp.h and slab.h from radix-tree to lib tools/include: Add phys_addr_t to types.h tools/include: Add _RET_IP_ and math definitions to kernel.h tools/include: Update atomic definitions tools/include: Add mm.h file tools/include: Add cache.h stub tools/include: Add io.h stub tools/include: Add pfn.h stub tools/include: Add debugfs.h stub memblock tests: Add skeleton of the memblock simulator memblock tests: Add memblock reset function memblock tests: Add memblock_add tests memblock tests: Add memblock_reserve tests memblock tests: Add memblock_remove tests memblock tests: Add memblock_add_node test memblock tests: Add memblock_free tests MAINTAINERS | 1 + tools/include/linux/atomic.h | 2 + tools/include/linux/cache.h | 10 + tools/include/linux/debugfs.h | 5 + tools/include/linux/gfp.h | 28 + tools/include/linux/io.h | 5 + tools/include/linux/kernel.h | 6 + tools/include/linux/mm.h | 42 + tools/include/linux/pfn.h | 10 + .../radix-tree =3D> include}/linux/slab.h | 25 +- tools/include/linux/types.h | 10 + tools/lib/slab.c | 38 + tools/testing/memblock/.gitignore | 4 + tools/testing/memblock/Makefile | 54 ++ tools/testing/memblock/asm/dma.h | 5 + tools/testing/memblock/internal.h | 12 + tools/testing/memblock/lib/slab.c | 9 + tools/testing/memblock/linux/init.h | 34 + tools/testing/memblock/linux/kernel.h | 12 + tools/testing/memblock/linux/kmemleak.h | 18 + tools/testing/memblock/linux/memory_hotplug.h | 19 + tools/testing/memblock/linux/mmzone.h | 35 + tools/testing/memblock/linux/printk.h | 25 + tools/testing/memblock/main.c | 8 + tools/testing/memblock/mmzone.c | 20 + .../testing/memblock/scripts/Makefile.include | 17 + tools/testing/memblock/tests/basic_api.c | 896 ++++++++++++++++++ tools/testing/memblock/tests/basic_api.h | 10 + tools/testing/memblock/tests/common.c | 27 + tools/testing/memblock/tests/common.h | 15 + tools/testing/radix-tree/Makefile | 3 +- tools/testing/radix-tree/linux.c | 27 - tools/testing/radix-tree/linux/gfp.h | 33 - 33 files changed, 1397 insertions(+), 68 deletions(-) create mode 100644 tools/include/linux/cache.h create mode 100644 tools/include/linux/debugfs.h create mode 100644 tools/include/linux/io.h create mode 100644 tools/include/linux/mm.h create mode 100644 tools/include/linux/pfn.h rename tools/{testing/radix-tree =3D> include}/linux/slab.h (61%) create mode 100644 tools/lib/slab.c create mode 100644 tools/testing/memblock/.gitignore create mode 100644 tools/testing/memblock/Makefile create mode 100644 tools/testing/memblock/asm/dma.h create mode 100644 tools/testing/memblock/internal.h create mode 100644 tools/testing/memblock/lib/slab.c create mode 100644 tools/testing/memblock/linux/init.h create mode 100644 tools/testing/memblock/linux/kernel.h create mode 100644 tools/testing/memblock/linux/kmemleak.h create mode 100644 tools/testing/memblock/linux/memory_hotplug.h create mode 100644 tools/testing/memblock/linux/mmzone.h create mode 100644 tools/testing/memblock/linux/printk.h create mode 100644 tools/testing/memblock/main.c create mode 100644 tools/testing/memblock/mmzone.c create mode 100644 tools/testing/memblock/scripts/Makefile.include create mode 100644 tools/testing/memblock/tests/basic_api.c create mode 100644 tools/testing/memblock/tests/basic_api.h create mode 100644 tools/testing/memblock/tests/common.c create mode 100644 tools/testing/memblock/tests/common.h delete mode 100644 tools/testing/radix-tree/linux/gfp.h -- 2.30.2