From patchwork Sat Oct 19 02:37:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13842539 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 2BC3DD3E1A8 for ; Sat, 19 Oct 2024 02:37:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7EBC96B009D; Fri, 18 Oct 2024 22:37:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7743D6B009E; Fri, 18 Oct 2024 22:37:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6154B6B009F; Fri, 18 Oct 2024 22:37:28 -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 4263E6B009D for ; Fri, 18 Oct 2024 22:37:28 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5EBCB4058B for ; Sat, 19 Oct 2024 02:37:20 +0000 (UTC) X-FDA: 82688789988.07.BFA81CB Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) by imf09.hostedemail.com (Postfix) with ESMTP id 7832C14000B for ; Sat, 19 Oct 2024 02:37:17 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=blAoSXjQ; spf=pass (imf09.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.52 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729305298; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references:dkim-signature; bh=vOpFRL/c5SphCdq52c5k/AoeTJgkTDqQ+1q96BtaNZc=; b=77QdjDX2dOYOPUtu8QuOYyGW62bp/H6cyzbHxqeGCZUa8y7hAy6j+6YFOuhJ4m6iQcpcwn Pj7x+TwZ1z7ZyGGGnAvOCCDHXOCGrR+QvQu66cdDpKRAp4MCGIBhcnP8mG/Aw+JD5NAiOD TOK3yumlHSP0ReX8iubShl1pZPf26mg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729305298; a=rsa-sha256; cv=none; b=MzUun+BnjXxM33BRm9rGct+Wp07OFs3h+5iSACaxGOlz3TfxePMNAEL7ezPEassXLEZzby Ue26hJB9SU6W7snZ1DC6480T/TRJiSB1T+03GM7lzpRUhGTjBaxdukQKPqcHUPJJ6wGk45 xyLJ9hKUzIum9Y8/2rwpPimTbGo83Ec= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=blAoSXjQ; spf=pass (imf09.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.52 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a9a0c40849cso394680166b.3 for ; Fri, 18 Oct 2024 19:37:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729305444; x=1729910244; darn=kvack.org; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vOpFRL/c5SphCdq52c5k/AoeTJgkTDqQ+1q96BtaNZc=; b=blAoSXjQ6MW7zEQpX28j0Tv7bu6JEFfZIHUKzvpZ/c6hCfbwZBJLCaFUQmPGoSIlCV AHCDZ4XEBcKQXLCcVI6BQBQlpmPLJXme9vDQvgrVRAV+Q9ZBSLCkAP4J6ljbL/14SHlz U0SZ01G6kAYiGSI/gWCESwXN6mn5x0FKWpXMAiuOrc8w4Z91M/F+ydBi3GJ4LtejeQZn cK17cWIw4VyvfBKNGK3PiFtrcTlH5cgkNzipYkSz0ciDFSmynw40cqI0sf1r89ypr1cn Rbs0xALIaKpC7s1dGISn864hFsdQsabbBUeyWF4OxUwLGu0fSPhUE0kGkAaj8JY4uosC pQ+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729305444; x=1729910244; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vOpFRL/c5SphCdq52c5k/AoeTJgkTDqQ+1q96BtaNZc=; b=chbsPzgt36YkEfGW/5DbrdWoymmvl59MSjvYOS0HZJ/VGNdk95RbYY0bw7b7nFXc/y mWGMdm+95qot+2JTvPKj5+I++kW+54pPR04X4GGsceSfswN/d5wDSPLC6eWHQG4s7e2y LN+KwJ5s+74AekYfzdUAfoT1ZBAjtRSPKiLywiA6AjXw7SiEUYwuL9LNBJH98dAybmry 7euVMnE+tyllBeW4gE1pwpyxbIqhID1as8l3wh2fbf2TmWqsA437Q9TCVGQEYTFbXa+L 63vzKD43gecPJ02oHG9wdjvt69+CqiFCs5Xfcr5HbJwWYVTSAP9qee/L/jngSSSKEhwY u1xQ== X-Forwarded-Encrypted: i=1; AJvYcCVzJW1MxDlGJOuynI0v3gA4M9D6HhS7ojMyMZju/tv+2hywkgAxO5x6QqrLoNDY1ssKkocXuk7Jkg==@kvack.org X-Gm-Message-State: AOJu0YzrcE7t4o1l7H8s2FSFANzgbnQGCiUBDgykTRyAGSdL0qE0wWXp 8ofyYZ/F+mJkrCh0MgzDMqKEQwcDGU/sfpvyr2pePiaJbKBn9M5L X-Google-Smtp-Source: AGHT+IGoArGoq7lf5qteP3jg4wfWWdg4FVLDQ3pEdVq2pOfJM1oTEyd8ggMTAG2Pf4756MRzlmNhpQ== X-Received: by 2002:a17:907:9813:b0:a9a:3cec:b322 with SMTP id a640c23a62f3a-a9a69c9c659mr426436666b.45.1729305444000; Fri, 18 Oct 2024 19:37:24 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a68bf7194sm160152266b.184.2024.10.18.19.37.21 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Oct 2024 19:37:22 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org, Liam.Howlett@oracle.com Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org, Wei Yang Subject: [PATCH v4 0/5] refine storing NULL Date: Sat, 19 Oct 2024 02:37:11 +0000 Message-Id: <20241019023716.4516-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 7832C14000B X-Stat-Signature: phwp8wrubpj87mdyw1mbkeex1fnjkzmj X-HE-Tag: 1729305437-164362 X-HE-Meta: U2FsdGVkX19HyFBDrKhfQC7Fvo1/BJ1AQh62ainMVfR3ZEV0O92jVFYdTVGnvjIep5CSO2tjahRLYl6+GlhH4k0T5ouSJx3zom7why0eO0Lzo3h1yCKeMhX7FnIJ+mPftm2oLwtp9e4X7NpUa+Z+mKKK00z/iFGv0TD5u1byvLYK4jSQxiZ0/c5EwCAX86ZknFyKLEr7Hzbr8L+WwDEjvy0QxO9G5M5XJ3GojqKWD6ljyZYLZxFqSptZ25qA9fvUYxzd4zpjOhKfA/ipCZEmQVDqME247MHtwbnMqmCPkSfJjyy7HQLNM0MM2ZWUPKVXC0rnIjZeJBOkMb/i1vBo4kxQcOk0LTJfhfVpo80d7Z/gTlyGwr9hSIE3kHEwdS/S3i6rlQKSvjnnncjAfsGSkxThH6lwcCkK+b7d2CLMGGWShAgKNRhFqNCGhKU+98BrmgXVg9BurOEQQOzWwecoaAutdER+fHbYk09p6eQhe4Tx7dBWz0AVernTs5m6AS2ieq3N/5nFK9r7naEYqPTrRiUD8nRUXwRh5wkN05ex05bsZc/ScumTCWaWTNZVuSiJrJJYM/R0Os//Dyc3NyT0zIgCUVyJHMII2C4a88OMukxcxQEv7L305YcEJ0mTn9gaU9jRXTBIO/KqNOHMAnTIjW6ecXBmlRB5C8Ya5SMA9TOK2cD5PgpvnnfB764tcRxwkNALETOFs/oqcTIX+H88HRyzkqBa+BP4LteTEzLxMm+cn88UjlxAD98A7Cp2KQHGUVq0Q5WUA1ZLKuEtyzHS2B9d3RTIe3Dl+Zl7aIg80LO2E9w7vAL5e0t1xYKNmgy/q/KKLTTBl4YwqzfIPzM/nOdJPo/bxzI31kX7j7Mm5S8uyQR/U+i9/kVE0zU2ekKubT6bGC/EP3DtXrebno89cDKIsA1NbY5WmbhuPaTLPuqDfq93tAdM23oVJDvgbfYpYx2LW0FHyAPaccLt6CO xOA63GF5 sUMlVJoFdZdVL7RLnVlrfLBQxUnrGoNbwLtpy+CNCkvR77tuIm/pET34wUklr6GzLvbpeuHIrvAflwzad7ozWFfuPS8stqggIpRIdQnFPfFHu2AD5Q34tLzjU4RFzyTF/ZlqbgwtnAmwJRp0IHd4Y/kU8d2J4xwioOZMv0slCiBiWbLjwC01JMk2W08kqZ8lAk5eZtBeP18it8CKbS5NbGgAhL1IrBsKlG5JKULVJqeE/aKD1RjlLQz86MA/HfLwc+3DqMIzSxekbX9rCZLPSWzdptm0B82lucVGD6110+xMn5Dhf/YZNTNsi508zPhQvxjiN4csSCaqALFPRT4YEInj9ldaFS/u2ptkwH7uQ5LDNbW0OR/KO2NxImPKVfcdqbb+24uo48Lx0PA2ti963V7dhlwLlo53DqpE9Ezg6Z3oQAI4IlMxEkwMBLsy5K+SoThjikLZXgTTkO38tgt+qJ+VSuQ== 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: List-Subscribe: List-Unsubscribe: The original thread[1] thoughts it is a problem in mas_new_root(). But after discussion, this should be an improvement on storing NULL. Patch 1/2 preparation for refine. Patch 3 remove redundant check in mas_new_root(). Patch 4 refine mas_store_root() to improve memory efficiency and remove possible consecutive NULL slot. Patch 5 adds a test for storing NULL. [1]: https://lkml.kernel.org/r/20241015233909.23592-1-richard.weiyang@gmail.com v4: patch 3 add a WARN_ON_ONCE() patch 4 add a comment and simplify the logic a little v3: patch 4 move the change into mas_store_root() patch 5 move test into lib/test_maple_tree.c Wei Yang (5): maple_tree: print empty for an empty tree on mt_dump() maple_tree: the return value of mas_root_expand() is not used maple_tree: not necessary to check index/last again maple_tree: refine mas_store_root() on storing NULL maple_tree: add a test checking storing null lib/maple_tree.c | 29 ++++++++++---- lib/test_maple_tree.c | 90 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 7 deletions(-)