From patchwork Thu Oct 31 23:16:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13858437 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 E7D3EE67490 for ; Thu, 31 Oct 2024 23:17:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 73C676B009B; Thu, 31 Oct 2024 19:17:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 67F7B6B009D; Thu, 31 Oct 2024 19:17:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A2806B009C; Thu, 31 Oct 2024 19:17:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 252FC6B009A for ; Thu, 31 Oct 2024 19:17:00 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D67B5C1880 for ; Thu, 31 Oct 2024 23:16:59 +0000 (UTC) X-FDA: 82735459254.04.F225359 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) by imf02.hostedemail.com (Postfix) with ESMTP id 28E878001B for ; Thu, 31 Oct 2024 23:16:01 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=GcwZenhl; spf=pass (imf02.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.42 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=1730416399; 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:in-reply-to: references:references:dkim-signature; bh=0lssgk63PrG0F1GiC5EiShIsBNyhgWemQsSMEdRh8q8=; b=uCW3CWtGSBchf40zz7UY2h9fS/62/KEauVHGotyQrHIMEvuwsliQp8sXXY2S41TYz6WLj/ QFEjhQaYsWDHpA+D2lWdjwE2f8zjdl8T/TFPzKMZ3Uad2dMezxPV92HsrrWstQcS0eHyEz tnOF3nr/I+Ez6dMHLpGs2L7YM1FfhhE= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=GcwZenhl; spf=pass (imf02.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.42 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730416399; a=rsa-sha256; cv=none; b=nD5ttxD3XAvxf69N15mw9oHRxWEdnuXLNtV1TK/KggHAhm2ZkH/qC7kj7o/MqMjvMLJeh6 QF0SyFy/CtRmtXozHyJcb9oi69FNrI108jjSbXJUog4wqq0FYspz5HQFexZkjgfma5bmnO u467nfuYDdRiQqxobDhSdys4jVdgaN0= Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a9a0f198d38so217778666b.1 for ; Thu, 31 Oct 2024 16:16:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730416613; x=1731021413; darn=kvack.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=0lssgk63PrG0F1GiC5EiShIsBNyhgWemQsSMEdRh8q8=; b=GcwZenhl7kum18ksN0+N5dJLvX2/4X4/DJw1dC1ClFzPyyqJvEXuvpHgKmy+JxhhS7 ny4quGiFvYVafEraorvE0Dj9MiABwTViSweKk39IVCAST0EW4Oq5ifr9GFNcVlZo7Hyv ZhklBM9YbahoP/7W0LvwHAjBgFCKHzWB2pCp0fEw1Au5A63LTZNA4d/CcVQDn5py0TlC qDQFdLM942NJx6yvzxYI+E4M4nDowEA7z9bt4Vx4Uy29wGlE5lO94uwPfEBsRpBpHi6F e3Y2ghxTWsd2QSWHvtfLM4HEEMdOts8smlXITdGsCOdqYkabEPkS2FglBmg5bNFsfXPR IHQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730416613; x=1731021413; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=0lssgk63PrG0F1GiC5EiShIsBNyhgWemQsSMEdRh8q8=; b=Tpi+PqOImvIJNYYv3o3QLJGcXmj2T0XJb6bUuJXCkoLLe/PLPZgFi96uIhCGINr+rq cYgKDj7wLPA2Z2GR/LqyBVrYR5+G1Ytetmhx/E/NBsBiZh+d4zUp5cVTI8iIpb3w21QZ MF8JCnGOvv1K7A8jcU4hnCA6VtuZyMBJWdmijEG1PcXi7ME/buLpzV10u8P06wIOTo3Y xn1cixz53b/J9gd0U8L04yWUKnoaF+/T0GhZxncvITtWwAFMl58WLzR8Bs/VHTJjPec8 ErpF8DnnpXC9U5rXnD/202LN0iRCug8vfG851L7nnwwQ0ft9yuJTRr9huFdOa0G1jKzP BPrw== X-Forwarded-Encrypted: i=1; AJvYcCWWunRxkLTLIlKYnP/ycroHHL2JF6cWcRYJu9KX33k1/rKAnwEm+12fOjfhV0YqZ/jEzpDkth8yaQ==@kvack.org X-Gm-Message-State: AOJu0YybM0LMbeAVl6a+VkbQOKdg5N5yXQs8kfyyr+dk0Z40RIuH8wLc JqqVpThkYrbl2S+GDrCUBkEpeBYpPxJTDz41LbFxbsA8lUZogbM0 X-Google-Smtp-Source: AGHT+IHNsUN7FcAQIsdM/3jaLFreiYqGkBILS0Zj/u6ZBY3NxO0WIPYxStivLHmPqkN04A/pyXQ1UQ== X-Received: by 2002:a17:907:97c1:b0:a99:4e35:9a25 with SMTP id a640c23a62f3a-a9e655b973cmr146531766b.44.1730416612632; Thu, 31 Oct 2024 16:16:52 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9e565df8f6sm116923166b.140.2024.10.31.16.16.49 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2024 16:16:50 -0700 (PDT) From: Wei Yang To: Liam.Howlett@oracle.com, akpm@linux-foundation.org Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org, Wei Yang , "Liam R . Howlett" , Sidhartha Kumar , Lorenzo Stoakes Subject: [PATCH v5 1/5] maple_tree: print empty for an empty tree on mt_dump() Date: Thu, 31 Oct 2024 23:16:23 +0000 Message-Id: <20241031231627.14316-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20241031231627.14316-1-richard.weiyang@gmail.com> References: <20241031231627.14316-1-richard.weiyang@gmail.com> X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 28E878001B X-Stat-Signature: bq4yos39xf3iotzkg4kpgp49tsbdbsuw X-Rspam-User: X-HE-Tag: 1730416561-505099 X-HE-Meta: U2FsdGVkX19LQpzMeDifyfDUHMwg7qEfCcLIKiUh3JRBwF8CJZo0VqJcynDTIvEd4Mgw6ZP5EO0nFFXlTdvTUF0jRpP3+JukgQ1AnQLe3EJaX2lyfHrc6wWa+buZons4SiRr7JGJDE/ybdgTykXSq2Av09I/rquf5m89JpnWtM+17BWnLioClI8R2Q529S7CNFmtCrOC4xmSQ5IZDIQgyT7ro4Ed/VhKPwjZ8QzLb5Zsj7vsAUw6lssGd2TJs3EukOJTnW4bgHNtZRallE9Kdr2YE4tJP9gKWi4+UXMCpm51RXXYjZ6OdM/ZiMqNqcgxjkl3zbhdq+FP9pUeAmcX7aoqejMsoy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xUL1db9PKtKY4OlPqx1VRecGKcCshcEp4xWsypfmkJNoM21/LN4rC5wA26A6Ptd+/Ea+AyEX 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: Currently for an empty tree, it would print: maple_tree(0x7ffcd02c6ee0) flags 1, height 0 root (nil) 0: (nil) This is a little misleading. Let's print (empty) for an empty tree. Signed-off-by: Wei Yang CC: Liam R. Howlett CC: Sidhartha Kumar CC: Lorenzo Stoakes Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 38aa8abf8eb8..523355fb2bbe 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -7273,10 +7273,12 @@ void mt_dump(const struct maple_tree *mt, enum mt_dump_format format) pr_info("maple_tree(" PTR_FMT ") flags %X, height %u root " PTR_FMT "\n", mt, mt->ma_flags, mt_height(mt), entry); - if (!xa_is_node(entry)) - mt_dump_entry(entry, 0, 0, 0, format); - else if (entry) + if (xa_is_node(entry)) mt_dump_node(mt, entry, 0, mt_node_max(entry), 0, format); + else if (entry) + mt_dump_entry(entry, 0, 0, 0, format); + else + pr_info("(empty)\n"); } EXPORT_SYMBOL_GPL(mt_dump); From patchwork Thu Oct 31 23:16:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13858436 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 36A05E6748F for ; Thu, 31 Oct 2024 23:16:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A94E76B0099; Thu, 31 Oct 2024 19:16:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A1DB16B009A; Thu, 31 Oct 2024 19:16:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 86FBD6B009B; Thu, 31 Oct 2024 19:16:58 -0400 (EDT) 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 66B9E6B0099 for ; Thu, 31 Oct 2024 19:16:58 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C976BC1A17 for ; Thu, 31 Oct 2024 23:16:57 +0000 (UTC) X-FDA: 82735459170.04.89E1427 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) by imf23.hostedemail.com (Postfix) with ESMTP id 1B435140010 for ; Thu, 31 Oct 2024 23:16:37 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="QfoS6/2i"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf23.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.54 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730416535; 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:in-reply-to: references:references:dkim-signature; bh=PfcQibdN0gqKBuNuHAxsEL4fK669tNNDHj7Em8iN560=; b=Pl24TF9Flvt0LXT7qebZuGuWNgiFuET+VxuB6BEwEH6BoPdcEve5Xil3V7FEIeAHSflJt/ J9grhcGWtwufHLJaTdN0EDWItvytPtM176FoS1TVWTnLNt4Imc5lHKpQQXwtZOLCxanade ddm4OtEhTmaVqgrG3Jch6NZDLwXXoJQ= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="QfoS6/2i"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf23.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.54 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730416535; a=rsa-sha256; cv=none; b=tXgfBu34OLrD17sTi63fTk+d91PSdBp4t1AXBgtRHiYm5E95QGieLMW8tGhbyEpbRsPSH/ KYNIFw9XTUGNDkTcwxGKuZ8KITJTztp3xuRkQiHhljEmBAKsLKKQEc/kDYmFyhwqAMra1d 0q1VdFcOmanYiUTOQomHa+6qb0ibjO4= Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a9a68480164so197124266b.3 for ; Thu, 31 Oct 2024 16:16:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730416614; x=1731021414; darn=kvack.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=PfcQibdN0gqKBuNuHAxsEL4fK669tNNDHj7Em8iN560=; b=QfoS6/2iZwvU0pwD2mziIlqkap34JxcUKwMEuPp+VV6DThS/9UrkkALM2oGzYR6hGb bIJsPvPyor5nrEOF2eu6JN0U2XCGvF8GyoyRo5HJ34z3qjJm9vhGbqVSudUvFNtalCsh fSBfpUcdplC/kv3XdouJ6YWHFAtXVAqwfHqH3LorfnERUXyfkqck8KPK6So/k/GSEazp bdpwkHTklp4hA+wdseUoiv94Ryop4ZojV8WwPahjt4jKMa7IBgoCfXVTLGVmOTfxyF/M l6Lg9rwxhrjs6rRIBW2hXm1sMTLa5N3Dq2A2CFg+alOcM/L6hzBAncK/QCkGm75HZyUE MgTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730416614; x=1731021414; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=PfcQibdN0gqKBuNuHAxsEL4fK669tNNDHj7Em8iN560=; b=oNpa0Ph46X28EgXznrD6II/tKV09CedyQdHanh4qD/xhzo8j2YH2tqUFarzM9Cqrv2 zdNnXct6x9qaeOcY962torLjzZTp7NqxP7Mlb48tiIkQSMq7qTSjrbiCO4ZAsx0kLYmd ppRoFmkOmNLFQCMqJWOqEAwTIFGVNMSHoxIet53NNPoai9oQajgHhfkQ4nHHvjjy2Nif Ztn8FbGlgcJdJfQS2m/VTJNpyDcCOyZpmLGRoseTMips1qz1vKItFSVroxXuOML/ziFe nRs6bz8HolfMcrM+Xw5YIeeaUktWGJamsKUrJGFYb+JlC04Y1Kcf1cgMe0O16Bf/uVqQ qIoQ== X-Forwarded-Encrypted: i=1; AJvYcCW4givfegJTWl5OIykogWux5LdKerD7zdwxD0PeU+dDeKscnskCEeKagz/dvYz2QZyrccIot7FKVQ==@kvack.org X-Gm-Message-State: AOJu0YxwVhsHvQFwXXR1P9wLDNhEsj+RwE8j9ZCJrqRQzvUSkDHYhlI3 Inl0Jvf8DC6Hv1oOjYWcrXyHYX9CbQXApyKVFI0PjxQMSMfGI4TS X-Google-Smtp-Source: AGHT+IEGjC6Ry7TP2qxzVByBxXRbzE5PIaQkwQZ585pLYrsxJFc5JDMnz8Pmo0J8uk9jR782pIUWfQ== X-Received: by 2002:a17:907:9723:b0:a9a:5b78:cddc with SMTP id a640c23a62f3a-a9de61bba35mr2284479166b.64.1730416614395; Thu, 31 Oct 2024 16:16:54 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9e564940c5sm116906766b.16.2024.10.31.16.16.52 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2024 16:16:53 -0700 (PDT) From: Wei Yang To: Liam.Howlett@oracle.com, akpm@linux-foundation.org Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org, Wei Yang , "Liam R . Howlett" , Sidhartha Kumar , Lorenzo Stoakes Subject: [PATCH v5 2/5] maple_tree: the return value of mas_root_expand() is not used Date: Thu, 31 Oct 2024 23:16:24 +0000 Message-Id: <20241031231627.14316-3-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20241031231627.14316-1-richard.weiyang@gmail.com> References: <20241031231627.14316-1-richard.weiyang@gmail.com> X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 1B435140010 X-Stat-Signature: 4zoc1nz1agnpoejyo9uks16t5ob4um7x X-HE-Tag: 1730416597-830534 X-HE-Meta: U2FsdGVkX1+y9qkIsQ41ZHAMzss5pZBMdrH8ctbcqCGow8jBcVRo7xadgxh7cesA5Muo6nRTZKTz57n6Lbqu9tkeu8ILwI1hrmrFRAwcpE1Uc2UDVCbDFU1plqONykYPo1V0bYKan5N7eO+FNiXLmLt2Jg/7wa0jnH4z/RGrNSZ8AoIh+NTucadT0mLo60khX/vvZzJ1+XHqILz7CtTD9Z92DZdoHtKlJF8kRTfWG2Cizr/zuTix+cbrAprFefZl0/ooYsO63lBLeFZJlPZXQQfkcrMx63X3gbZZOTwSroax+dsRYD3PTGUjmpe38i2EWBkIM5/6wP+vk0ZmQWLePK87xk0NxtcDq7vQqgij8tfRgW8yxY/ZYdzK6oePiZsWWU8IpjGcaaj7zULIaS6oZE5B5o1keHHI8P50QZOeWeXO3HE/+GTE2/eBp0JsppSvCsLF+VjmP2gICwYoLsXuWb/FHCrndO9zuCOpUPA1u+3+fWgqsYk2GXmoExQJ5jy2qsporaflkViIAnRDclIXqR4n6FdB5rbV9IA/1g9H/xqKCGOs8KtEkndwKXcspUL58pmeAULnRGIGMiGj9VxMCAHHdeWVaCUK/K6PJ0gY1wRDG3fI8wMskefkcOI7qoaxly9kluFN9bDUdwOugivZRNYInyKRvrUwcliPs+mR+h6nfneftLW8+wH/a94rJMjZSvOKPUv3L7T+/c7o+pgtVcmRcSE8Q9TBhWtrtS/w2wXcVS/hR9rkD5zQLQII/LH7fQ5geYLWhcmOCm7gI40lakZMYE/VTjXf2mQuzla9CiAvlQbSvfTvBMFVqY2QpBqMTmtiM86XiFDw+D/cfoXF7vvKO7OWqbmBXIFkJL/fm2m5J9rqC6+W4wJOVoVXx72fcwSTnrJ0xJyDvXFi5PC79LR0vuAej5vyv2/8uccAjd/UodkqAVpKwrtTplyvAW2eWENt8MyizyNrmX+ykkc WRwakMER L6CaoM8rRIvsomi19FMnUVv8pgh2tLSfRF43P8wXNe38fdGim94NGfYK8DyW42aOMYU+Fda2J4DeiBx7AGUpXFvHu1LVj1ONfjthGdBOEsFuhJgKbXegEzeKYnnIcpnyyjMkMI9ZjGCrcq3fOMa6iRocOpgkGAkZcfXbejGrd+OkPVBJv+A65P45tci4NeB50NqVJyvSs+GczBCNZOC5+4uq8FJMZdiOUL8kW0wGM0OVWiJeuCNIFqnMjihmrWJ1N0e9pkpPE4suMVYkwxxU9tK3HnsoZSW+t/Cf6YiDngXSKA6IzrRNSFWksCG8iWwGRHrMLiKkyw/R3wbDDbKyvAa3SQKm1SiujTiICvg/5qaq0ecBhEK6rDBb/7r8JoimbZO0wJn3Cn9kuTLnhEiUb6qwl+RPS22b/klsrurKAjB75/6a8JlKIYYWooKHrMGnfB+b0CcmGHCMFOXfkjmFnY89zyM+b2jAOnUaqsodnFLHAJDDBclZ8fWO01xUxaVDny8BY6Ub0Aop497GueT5U4ESMgZJfPPAKbfrH 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: No user of the return value now, just remove it. Signed-off-by: Wei Yang CC: Liam R. Howlett CC: Sidhartha Kumar CC: Lorenzo Stoakes Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 523355fb2bbe..071d3055f1fa 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3408,7 +3408,7 @@ static noinline_for_kasan void mas_commit_b_node(struct ma_wr_state *wr_mas, * @mas: The maple state * @entry: The entry to store into the tree */ -static inline int mas_root_expand(struct ma_state *mas, void *entry) +static inline void mas_root_expand(struct ma_state *mas, void *entry) { void *contents = mas_root_locked(mas); enum maple_type type = maple_leaf_64; @@ -3444,7 +3444,7 @@ static inline int mas_root_expand(struct ma_state *mas, void *entry) ma_set_meta(node, maple_leaf_64, 0, slot); /* swap the new root into the tree */ rcu_assign_pointer(mas->tree->ma_root, mte_mk_root(mas->node)); - return slot; + return; } static inline void mas_store_root(struct ma_state *mas, void *entry) From patchwork Thu Oct 31 23:16:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13858438 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 659D9E6748C for ; Thu, 31 Oct 2024 23:17:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C68D36B009A; Thu, 31 Oct 2024 19:17:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF20B6B009C; Thu, 31 Oct 2024 19:17:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 959736B009E; Thu, 31 Oct 2024 19:17:00 -0400 (EDT) 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 622AD6B009A for ; Thu, 31 Oct 2024 19:17:00 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1C321ACE6E for ; Thu, 31 Oct 2024 23:17:00 +0000 (UTC) X-FDA: 82735458288.09.CB34A93 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) by imf22.hostedemail.com (Postfix) with ESMTP id 455ADC0021 for ; Thu, 31 Oct 2024 23:16:24 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=dkPpjfeb; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf22.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.47 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730416456; a=rsa-sha256; cv=none; b=njI2Hm/biI9xE/td42SCWgH8YWD5ijx11APGog2HSB4M7aZqNxAOZoG/7IgZpUVHp4yY2Z l6l5i2oL+OZbue/g9c7gQmsjPPA1VhjNydQlF651KWUzAAZGzgw9xXjTKL4RyKJTaCPteT X7O8FIBqx984AxZLRGEcr6K0HXou3vM= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=dkPpjfeb; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf22.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.47 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730416455; 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:in-reply-to: references:references:dkim-signature; bh=gcFqE4Oz6KR49+L44Z8kkADWOf7Ogr19DZkDm6Ror8Q=; b=oUCfhPMJu36T3egRNBDNs+6ybPloVUo9qCst1GnnTDkPvfy3d++Cd//BP/uWZEoZja4E3W Gz6W9Q+zjXvu8spF6Ec4HQXpdQea9i0k8/QkpgE1gyPfv700KDoI/l3N4bGt6ZicFOLcuL Exw7+9O14m8lTJXbKrkIqeM1nZObej8= Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a9e71401844so3220166b.3 for ; Thu, 31 Oct 2024 16:16:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730416617; x=1731021417; darn=kvack.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=gcFqE4Oz6KR49+L44Z8kkADWOf7Ogr19DZkDm6Ror8Q=; b=dkPpjfebfiFP1TliK8ezEwNPeClb0Q1S1QajnVoPLm0LPwJDBWkcgdGKMnvjO/7rjU quJnwdcXqpWwbDRFiZDRM2iyoTwge0Yk/iKE6qVkmrjbZY/Eb/t+wGwVSRuF2iRisWeS QQuL+87dkaPTQ05DY21o+wBTnQP7QS0/yX8Gmhi2M1srhsMuU0xoNdwGl1pnJCgBpIlk WfQQwSCweyCVBsto3TYtXzskcnyji4QZ9NSQTffuOYVoLNN4Ot0fOQ+ikrmfC0B+vIw+ NtE7SrMdgglTmrwS+aQcZJ3yASQIUvcoaJE2HF3G/t0CVVpqfi+vvQnkPYu5Tcis6hVh 2RWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730416617; x=1731021417; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gcFqE4Oz6KR49+L44Z8kkADWOf7Ogr19DZkDm6Ror8Q=; b=fIXQfHnudDoRnnisJZpDaH6FEzkK18/rxFZT2yTJ6lChbPJQnrXXSGhCVl8JAPl1hW mmmtSXRFnaqTnRFnGw4sbXTCesxOh/tSaESj+rcKSItX1oqe+kEhjwbqPHsSikda64oZ tFtTj78JcZhcW/LWrhDW8RKznyCXizngPJ72JIBU0m4QyXmTNFkm8FF2ZphnMfmUhjLY sDJ2fok6yAnElYiXs+6kaJ4ImXvEj3UMJRllUldVeDyYCdd5qmaTvb7AzFzmf6dre9pH jLTvHFVuUe9QO3mFl2hmF56qDSVlxHRnSD1U6W0oHfEH/SVeh7VeWhfj5RTGggO3/hk9 jtUQ== X-Forwarded-Encrypted: i=1; AJvYcCUD9NPRWNFRUTh2u739nqjgksInitAOB6U6P29aCvkjfk0J5zS+9C4PSbCaRjAqCkmUeAPxPaXtvA==@kvack.org X-Gm-Message-State: AOJu0Yy9egBaH/DTavzldN0D/mvYOx87GtJHI1ZLJNqYFsCfI1xMtFIk CG47Lawc7HcSWELn0rwe97+fJ31lMfKNij29gB3BsU2WR9z3WU7t X-Google-Smtp-Source: AGHT+IG/zNXGzQh7mt+iQBuSF34CRxeFuf8RWx9qdbSGI/o9kzmtSVGeo/HU2aoVMhKKGpLZdJsjxA== X-Received: by 2002:a17:907:2d0d:b0:a9a:59f:dfb9 with SMTP id a640c23a62f3a-a9e508ace9bmr476289366b.5.1730416616737; Thu, 31 Oct 2024 16:16:56 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9e564c5327sm115126866b.56.2024.10.31.16.16.54 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2024 16:16:54 -0700 (PDT) From: Wei Yang To: Liam.Howlett@oracle.com, akpm@linux-foundation.org Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org, Wei Yang , "Liam R . Howlett" , Sidhartha Kumar , Lorenzo Stoakes Subject: [PATCH v5 3/5] maple_tree: not necessary to check index/last again Date: Thu, 31 Oct 2024 23:16:25 +0000 Message-Id: <20241031231627.14316-4-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20241031231627.14316-1-richard.weiyang@gmail.com> References: <20241031231627.14316-1-richard.weiyang@gmail.com> X-Stat-Signature: 67pt6riu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xD dI5GM2NV9CBFhN75vXAUZvffxH50i2uQr+3j36WhZWG8GCLu8qdl6fHliSk2Tak9vUi/w/8j8r5pYbS+2Efnn8xR8zucf4dhOmKhbdZLM12FqPNWoepkDVYMW4WETI/EFGtqZsq26WVmAu0HhLWae85x9NkJ/DztkbEf+KppZrxcKXsGG0hhGv1TVHcDhBtWHD/gaf/UhQhtvEeAb5NQsI1/9Avyx0pZSIgdSccCnFHJx6D/tEBq6z0g3CqQEZsY82YBD/mJtVhZNkzmTkZu3jCkblI4kIDH/eHa+3wIjjoIdg+jQU4kreneRRNlgNIch+XnTPImdt5paMVIjuTnxnaAl1DWT0R93MaxdnqHiIrorQknMgDmWhjifsz1EDq73oX1YPf9BvOVqR49nAYrMp+Lpy37xPwxp944QIVxkBAz33AQWvev7LvTCu5eSpTwjnS7X2iXPXJ+51VjnvfWINPSJiyxzkTsUdt3eL5AxwOYAK8Pi462r8PXLyfZJCqgum1pV X-Bogosity: Ham, tests=bogofilter, spamicity=0.000256, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Before calling mas_new_root(), the range has been checked. Signed-off-by: Wei Yang CC: Liam R. Howlett CC: Sidhartha Kumar CC: Lorenzo Stoakes Reviewed-by: Liam R. Howlett --- v4: add WARN_ON_ONCE() to check mis-usage. --- lib/maple_tree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 071d3055f1fa..4900f182e99d 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3670,7 +3670,9 @@ static inline void mas_new_root(struct ma_state *mas, void *entry) void __rcu **slots; unsigned long *pivots; - if (!entry && !mas->index && mas->last == ULONG_MAX) { + WARN_ON_ONCE(mas->index || mas->last != ULONG_MAX); + + if (!entry) { mas->depth = 0; mas_set_height(mas); rcu_assign_pointer(mas->tree->ma_root, entry); From patchwork Thu Oct 31 23:16:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13858439 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 25C03E6748F for ; Thu, 31 Oct 2024 23:17:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2302B6B009C; Thu, 31 Oct 2024 19:17:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0FF396B009D; Thu, 31 Oct 2024 19:17:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E3C3A6B009E; Thu, 31 Oct 2024 19:17:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B785B6B009C for ; Thu, 31 Oct 2024 19:17:01 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 7B58EAD920 for ; Thu, 31 Oct 2024 23:17:01 +0000 (UTC) X-FDA: 82735458456.13.AE3FE22 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) by imf07.hostedemail.com (Postfix) with ESMTP id 492214001C for ; Thu, 31 Oct 2024 23:16:21 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=N2zPQqoV; spf=pass (imf07.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.46 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=1730416538; 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:in-reply-to: references:references:dkim-signature; bh=oMVXV57zFNyKC6hSUbXS6uwPipyiopxuXakojloGh0Y=; b=3pJ8ITuKptsK353KEw7CfZbp/KXWO55SwJ2/0xZQiHwOsCzSLpeRD4s5hZtWfhzAh82dPd LwKUQqFoH+vc8IubTc9v45Q8Aklf8ACF1HEvpRpoixy3BZcew8mACIO3TjxPEeAIXtxq68 ROKiu5C8XkKO4a9uJsiczc49DWqsnGM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730416538; a=rsa-sha256; cv=none; b=y88QclKoy0gAPaOV19jlFrSR4CfyZqwAYmdjdRg7UQPYWXYTGfH4/YMbj6fcnzb6NP+cLK t4Cx4+JURgP+MO3m1vtuCbAnYNzWI85kRXdZY355ToQtjtb+yJbLFrs77gCE8jAENsj4nT Smqz0OKkpNw5GziHAxrjPd9sX+sahjM= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=N2zPQqoV; spf=pass (imf07.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.46 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a9a26a5d6bfso213893866b.1 for ; Thu, 31 Oct 2024 16:16:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730416618; x=1731021418; darn=kvack.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=oMVXV57zFNyKC6hSUbXS6uwPipyiopxuXakojloGh0Y=; b=N2zPQqoVjG1y8qM12AMAYQATE5VD0wqLkmfyv4yjPP0d2uHmasKKOSatK19jDhl07s CUiqrE7LG+rG5WfuKZgJiY4FWjcQaz6IwNAYie+kxQV7OE7m+yhHmT6vPLgSph+jbseW jiyexfmX8sJEkJOx/EmPVt0n5RkBmGzFAzQFgq2yJlw0Ac0Y+iQ6s2bMx/z3HxS//I9a FniT9oIdnf6kNDibs5cYV2+Hs0psI/+yUB6hlos9Ke0K07dUf6bRWQhq7aYctOM453Sn m3ncTADJf5lBspG4av6WfMme8gE1FXQORm2Y4WN1cz/ETEWBb7LiQTb9K5H0WvTyzHgJ uTGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730416618; x=1731021418; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oMVXV57zFNyKC6hSUbXS6uwPipyiopxuXakojloGh0Y=; b=wGPylW20mJTuph2bZaNeGJY3nPov1PEC0yvzGIaviS7r4xXGPWy0/K7JX1YfldjnSX HamObM3YFaOHw6r6rRAu2q0O45c8Gy66C2R5bJpmCmaVl7fyI9GCstqRJBNuCtALXh7P im4cJNUhmyAqm3IjYH+Uh/Pjm0l59MugpRneGVq6jeiIpm4pN/c5Wox1bJWE/Uz6h7es NFpj0N/mCFogZA65yWhI8iGX5fTOLBXkrQkInoy/RwxmevX0dvbRVOsrc5buAUqdAenY NkrZDN96YRF2gIJVwNse8rq90wMr2BnpnDLjVLEq++w6LA1rHp+ixX9IoEnVuQSdFU7b waYA== X-Forwarded-Encrypted: i=1; AJvYcCXf4ejUL1gBnyVWOXbs/4H7s+Fu8RIBDfYk+mMqNgv97TUMIl0LDYA9WNfiOZk6obBUUK0H7L51tA==@kvack.org X-Gm-Message-State: AOJu0Yz9rJs4COdYTLGciAuHit1cY9n5Hk3sNzAFrNjdS/L7mp04+PmK ZYoFc9J2Q4QvjAs1GBnyiHzf8BZLwUvtL2+YI0ZG+bfmJRcFl3RYpjC7dA== X-Google-Smtp-Source: AGHT+IEdYHF6rz8qzh0nA6nPkS0yzoExsZJUeLNX6F3y+CNyUQTmzJjR9k+lqrh/i61OAOJa+7FEIw== X-Received: by 2002:a17:907:2dac:b0:a99:6791:5449 with SMTP id a640c23a62f3a-a9e6587df7fmr162789966b.52.1730416618160; Thu, 31 Oct 2024 16:16:58 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9e566435d9sm116909266b.171.2024.10.31.16.16.57 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2024 16:16:57 -0700 (PDT) From: Wei Yang To: Liam.Howlett@oracle.com, akpm@linux-foundation.org Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org, Wei Yang , "Liam R . Howlett" , Sidhartha Kumar , Lorenzo Stoakes Subject: [PATCH v5 4/5] maple_tree: refine mas_store_root() on storing NULL Date: Thu, 31 Oct 2024 23:16:26 +0000 Message-Id: <20241031231627.14316-5-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20241031231627.14316-1-richard.weiyang@gmail.com> References: <20241031231627.14316-1-richard.weiyang@gmail.com> X-Rspamd-Server: rspam10 X-Stat-Signature: ugrkxju71hxhnt6a71k8r18x9ru4gcfo X-Rspamd-Queue-Id: 492214001C X-Rspam-User: X-HE-Tag: 1730416581-192776 X-HE-Meta: U2FsdGVkX19dIjpQxAn1dqK28O2v1M5DDTn23CigAdXhJ02IOj6tmMTjHx3Fe770FDRLweb+d/XJTel1r5DOxTDtbjkCEEUC1EEIcolz+QxVf+vxzX/nwDRn7g5CmZ4w+PxB5+2toNWZgZ6ifJSxvip0zSDea4cpIZXsCzzzqEEpEAYacAQLtNe2ER0R3cmyrFXhlWN48TeEpfdqbrtsNu9I/pMWcPvPai3Gagso3L6Ls93HjLSXZwkxZqmLATZzIxd5mx3Z6ZA8nEzPn6FS2NQcLbcdDmhVVS6e2xmzgHUehU7vt8I9hosxk9scOz8pIAY5xYfqRd4cHNbz7KYzs0fLWW8Oenp91KV91prUwa5zH7l9sKgk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KOgnLLL+N9hI+GRp6EcFnE4IFkxaT7/I+aZ292c/z3Ca6CyFL/ymsNZ 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: Currently, when storing NULL on mas_store_root(), the behavior could be improved. For example possible cases are: * store NULL at any range result a new node * store NULL at range [m, n] where m > 0 to a single entry tree result a new node with range [m, n] set to NULL * store NULL at range [m, n] where m > 0 to an empty tree result consecutive NULL slot * it allows for multiple NULL entries by expanding root to store NULLs to an empty tree This patch tries to improve in: * memory efficient by setting to empty tree instead of using a node * remove the possibility of consecutive NULL slot which will prohibit extended null in later operation Signed-off-by: Wei Yang CC: Liam R. Howlett CC: Sidhartha Kumar CC: Lorenzo Stoakes Reviewed-by: Liam R. Howlett --- v3: move change into mas_store_root() v4: add a comment and simplify the logic a little adjust the change log a little --- lib/maple_tree.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 4900f182e99d..d0ae808f3a14 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3447,9 +3447,20 @@ static inline void mas_root_expand(struct ma_state *mas, void *entry) return; } +/* + * mas_store_root() - Storing value into root. + * @mas: The maple state + * @entry: The entry to store. + * + * There is no root node now and we are storing a value into the root - this + * function either assigns the pointer or expands into a node. + */ static inline void mas_store_root(struct ma_state *mas, void *entry) { - if (likely((mas->last != 0) || (mas->index != 0))) + if (!entry) { + if (!mas->index) + rcu_assign_pointer(mas->tree->ma_root, NULL); + } else if (likely((mas->last != 0) || (mas->index != 0))) mas_root_expand(mas, entry); else if (((unsigned long) (entry) & 3) == 2) mas_root_expand(mas, entry); From patchwork Thu Oct 31 23:16:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13858440 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 E6F47E67490 for ; Thu, 31 Oct 2024 23:17:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 89D126B00A0; Thu, 31 Oct 2024 19:17:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 821E86B009F; Thu, 31 Oct 2024 19:17:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 69B5A6B00A0; Thu, 31 Oct 2024 19:17:03 -0400 (EDT) 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 439396B009E for ; Thu, 31 Oct 2024 19:17:03 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0D8BB141B5B for ; Thu, 31 Oct 2024 23:17:03 +0000 (UTC) X-FDA: 82735459086.30.6F22178 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) by imf20.hostedemail.com (Postfix) with ESMTP id 1316D1C0012 for ; Thu, 31 Oct 2024 23:16:26 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=U2YjJcNE; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf20.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.54 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730416502; a=rsa-sha256; cv=none; b=d1n3FaSGZAXbF4uUv788yKW4R9dWGD9kKO2SdyIgWNJq3G7oapFVL7pWmx27WacjpF+7zk yHx/upW2mloITazBkdknHq6F6JaVPucjhRU8t0u5hIBxyNeYnQw0wWmYY46GgediZ4NgHd PM6RDthu554i6yXkfyVZvB8WLpiB2U4= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=U2YjJcNE; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf20.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.54 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730416502; 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:in-reply-to: references:references:dkim-signature; bh=P9CSRGwy1VJIBoSqz5GF5VVPAFI1YgXTSL6P1gi2Dd8=; b=DCgU2+kLv3nlJwubGgd1vzfmdP/lTWJnaqrjTSsP5gAXPNwsXl4ixUCUm2mjbiKjEGGc29 5HqnReVx7QB8QdQTJ3DiqNhQrUBnzNs+qakvLY9SAQ4obokPl2JmyhAmRgox/X5WyscFG2 7np+CHuOtniA1BbBJtjzoh0B90q34ns= Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-5c9362c26d8so3976973a12.1 for ; Thu, 31 Oct 2024 16:17:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730416620; x=1731021420; darn=kvack.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=P9CSRGwy1VJIBoSqz5GF5VVPAFI1YgXTSL6P1gi2Dd8=; b=U2YjJcNEXWo39ZCAig5J5EuJYq4QoHDGSzLJa1iBrbBQrutjD9lwEOBGm+msjV7QSf 5dlr7zeHedPM/+wFIOfLrRZzX0uK4dlFZmh/1dL6tkXEtHALRdRj1o1Z519uklCVcWFz ys8SWYMfW050b3zOJt9GqYWuzPruHHUi0LhjvHS5Fz3fnRKqKcHzuIfjDZbcwG9k5B16 9uT+zof1Ch1alsMt02d/qfoHReQYwuziSoCxkNx1X8zxrdZvPyM27SjyPLSeVDHIPD7O vixuc3+/34i6wSNRGve9ZvR1QmfIbbfr+cZ9CDKiUWxyLJb9gQ6Bw0ghP8ge2HA0HYMs YAZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730416620; x=1731021420; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=P9CSRGwy1VJIBoSqz5GF5VVPAFI1YgXTSL6P1gi2Dd8=; b=UGuk/yqo/5Ihnz+LSP3BMlFrLopZl2ZDLFW3EHYvGmXqvFsIBxjkL1LcfR6XVBUctk IfzwCdNVFwFwcd2XidaqmkNtLjFp6iiBsWyC80C/789I/2XIXfikvW7xPEHwHWmce+JG LVJ7MyNCcs4IAkJPpd7vbyuZsrgRIRmx3vDmeG5ds6re+cf/aMoW7jQtLyJZ+LHFMROG hQQJlv3HdGQnevx7K/ly4pRtSgmykRfMWBPWByct3tpcxNxL77RkEB03VdN3z/tu640S VLbnMIrT0HihK/OLmqK/bMUQmvOwkaAmOXXHoPfYS5ltudWIuCOhpBNAQKSUsA7efRGe McAw== X-Forwarded-Encrypted: i=1; AJvYcCUoIvYZQmsRczAa1krrMxPt4rhK/7mgDtkn3vztbi102aWKilqdCGYGyp1SJcE2L/4ZpjXN55KO+w==@kvack.org X-Gm-Message-State: AOJu0Yz7ux85rliQV/+Rm7HhQ8KM5XiEPsqMOtVwH3KDwXr7mT4iRstY FWc9WjF9ZUp/nO8BZh/BF2JGy+Au6sLwPE17BqqJmm+T28ZrdzF3 X-Google-Smtp-Source: AGHT+IFJ6tmN4yYb8ERMkaSpwtA+zX9Ypn5jLHsJl6p2VlTr8UwYTltK2X90Vlmb0rFEwLmBd2diUw== X-Received: by 2002:a17:907:6d20:b0:a9a:139:c3de with SMTP id a640c23a62f3a-a9e6549249bmr172423466b.29.1730416619530; Thu, 31 Oct 2024 16:16:59 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9e56679c05sm114176366b.193.2024.10.31.16.16.58 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2024 16:16:58 -0700 (PDT) From: Wei Yang To: Liam.Howlett@oracle.com, akpm@linux-foundation.org Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org, Wei Yang , "Liam R . Howlett" , Sidhartha Kumar , Lorenzo Stoakes Subject: [PATCH v5 5/5] maple_tree: add a test checking storing null Date: Thu, 31 Oct 2024 23:16:27 +0000 Message-Id: <20241031231627.14316-6-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20241031231627.14316-1-richard.weiyang@gmail.com> References: <20241031231627.14316-1-richard.weiyang@gmail.com> X-Rspamd-Queue-Id: 1316D1C0012 X-Stat-Signature: zyk6ba1gdah1a8dwnc58ewh775uxju7g X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1730416586-557005 X-HE-Meta: U2FsdGVkX1/hvX4ucoKr0i9BdVbh8A6yyOVWxJgTPeTdFYButy5C2dT+i33K1x57dLGvYvYbZwDVEfkyaTtYvJGAsICRSgOIbJ7RRwYO0zXwB/P/1EkePYWFB0WEY8q8hmv/O9RiGtNTxfD45M0vOvRfQpBwP8J3gCcjrY7y08jAAbDauq/MtuZz8VONkXaCIHshh98lJZYJnBvneYJBtCnD38LFhK9MnaRrEhgbwHPvYmYmLTmUp1lkcIXL8AQ0vbf/c+i2Fi52pR1fkOrgk5StT7nRQgFlivoN54ImXD9ovlh5TL/S5xIWpcTuFYnu7KJG5v53SiL77qcL5nxkutzO+k+RNWShrMnJWkjOv6+V1FPu1e3LJWWdis+GjpfxO3Wqy+HLqcRibLEiWqou0bAufSqhILErojYlU00VvjuOyS6iwZIrFPn1hTVY4rRKVAVnD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1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add a test to assert that, when storing null to am empty tree or a single entry tree it will not result into: * a root node with range [0, ULONG_MAX] set to NULL * a root node with consecutive slot set to NULL Signed-off-by: Wei Yang CC: Liam R. Howlett CC: Sidhartha Kumar CC: Lorenzo Stoakes Reviewed-by: Liam R. Howlett --- v3: move test into lib/test_maple_tree.c v5: fix a build warning on xa_is_node() --- lib/test_maple_tree.c | 90 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/lib/test_maple_tree.c b/lib/test_maple_tree.c index 31561e0e1a0d..6f76093170bb 100644 --- a/lib/test_maple_tree.c +++ b/lib/test_maple_tree.c @@ -1387,6 +1387,92 @@ static noinline void __init check_prev_entry(struct maple_tree *mt) mas_unlock(&mas); } +static noinline void __init check_store_null(struct maple_tree *mt) +{ + MA_STATE(mas, mt, 0, ULONG_MAX); + + /* + * Store NULL at range [0, ULONG_MAX] to an empty tree should result + * in an empty tree + */ + mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE); + mas_lock(&mas); + mas_store_gfp(&mas, NULL, GFP_KERNEL); + MT_BUG_ON(mt, !mtree_empty(mt)); + mas_unlock(&mas); + mtree_destroy(mt); + + /* + * Store NULL at any range to an empty tree should result in an empty + * tree + */ + mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE); + mas_lock(&mas); + mas_set_range(&mas, 3, 10); + mas_store_gfp(&mas, NULL, GFP_KERNEL); + MT_BUG_ON(mt, !mtree_empty(mt)); + mas_unlock(&mas); + mtree_destroy(mt); + + /* + * Store NULL at range [0, ULONG_MAX] to a single entry tree should + * result in an empty tree + */ + mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE); + mas_lock(&mas); + mas_set(&mas, 0); + mas_store_gfp(&mas, &mas, GFP_KERNEL); + mas_set_range(&mas, 0, ULONG_MAX); + mas_store_gfp(&mas, NULL, GFP_KERNEL); + MT_BUG_ON(mt, !mtree_empty(mt)); + mas_unlock(&mas); + mtree_destroy(mt); + + /* + * Store NULL at range [0, n] to a single entry tree should + * result in an empty tree + */ + mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE); + mas_lock(&mas); + mas_set(&mas, 0); + mas_store_gfp(&mas, &mas, GFP_KERNEL); + mas_set_range(&mas, 0, 5); + mas_store_gfp(&mas, NULL, GFP_KERNEL); + MT_BUG_ON(mt, !mtree_empty(mt)); + mas_unlock(&mas); + mtree_destroy(mt); + + /* + * Store NULL at range [m, n] where m > 0 to a single entry tree + * should still be a single entry tree + */ + mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE); + mas_lock(&mas); + mas_set(&mas, 0); + mas_store_gfp(&mas, &mas, GFP_KERNEL); + mas_set_range(&mas, 2, 5); + mas_store_gfp(&mas, NULL, GFP_KERNEL); + MT_BUG_ON(mt, mtree_empty(mt)); + MT_BUG_ON(mt, xa_is_node(mas_root(&mas))); + mas_unlock(&mas); + mtree_destroy(mt); + + /* + * Store NULL at range [0, ULONG_MAX] to a tree with node should + * result in an empty tree + */ + mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE); + mas_lock(&mas); + mas_set_range(&mas, 1, 3); + mas_store_gfp(&mas, &mas, GFP_KERNEL); + MT_BUG_ON(mt, !xa_is_node(mas_root(&mas))); + mas_set_range(&mas, 0, ULONG_MAX); + mas_store_gfp(&mas, NULL, GFP_KERNEL); + MT_BUG_ON(mt, !mtree_empty(mt)); + mas_unlock(&mas); + mtree_destroy(mt); +} + static noinline void __init check_root_expand(struct maple_tree *mt) { MA_STATE(mas, mt, 0, 0); @@ -3710,6 +3796,10 @@ static int __init maple_tree_seed(void) goto skip; #endif + mt_init_flags(&tree, MT_FLAGS_ALLOC_RANGE); + check_store_null(&tree); + mtree_destroy(&tree); + mt_init_flags(&tree, MT_FLAGS_ALLOC_RANGE); check_root_expand(&tree); mtree_destroy(&tree);