From patchwork Wed May 24 03:12:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 98257 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2564762vqo; Tue, 23 May 2023 20:15:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4iDrpOi/VKMlzCjZ4cBtYtJN6U1pDXGiU5UBbXBTU9lbdLyRI0ozaiwMEItT2hPgjqi1Gc X-Received: by 2002:a05:6a00:13a8:b0:64b:205:dbf3 with SMTP id t40-20020a056a0013a800b0064b0205dbf3mr1474069pfg.34.1684898154310; Tue, 23 May 2023 20:15:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684898154; cv=none; d=google.com; s=arc-20160816; b=RRp5MJPmcdswzGaD8jl1d0aPnr8YAaDDA2qXzJX1fc/o28p++LzrWi9RhTU9NXXuKZ DR4hYDVNznsWERi4o57wMeaAWNGimv+ar97Zas7vr/ttZ7L5F4O5lBFABkISQlXIdKth tMsfqX9qRwSBiDkMVnUDd7eq0I+YbvSA50aQzFjIHEgrY+BI+k4BrNm9mJNqgV8CrK7f m/l7GcP/eJ+DH+IcNwzLNqKLU9IpKxH/QuzHFfVVEfBCWKrqYJenKivGbBzbImcV2gOH JTRXQGH/oMP+a1l6Y2tmAe3FM9NZJvlyP1MmiBRypvZ6phv55prvvrDy+ZdAuEETHSfn zmHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+8PHSao7q3toNyfgfjr7peVeEA2aTJ4gzpmYB1pZW+w=; b=c/8Xq8BzdOuJN8thIQrgHVKrwNcRrRRH08W4KP0EUBEVEw8Otygn0nyldwxqkRkldc dcdbnVYtgbf2ew6BvKWl2fWxiJtBMa7L2QYMMXu0eO5xBAWLqUDS1bVq60Fz70ePuoP7 DsoRfK5ayRuQuVazNTtSNCCwr9fv0rdlfCOKutd6STtlzQmsoqgd4h5hOJdJnswRM7gJ nicN04+RnBcpPG4WEiTtBqSr+x6nVA/GsXw/IfDwG+QrLPeTF25DqzkmDLnkoVWF65nP CQJ+5C2ULhj8gNLDXnuJvk6BdHcb6D+3NAoN3QYcYQs1o2DSMd+gOVyxIYnHMke7r0MR cAkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=lvWQ23Bp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y7-20020aa78f27000000b0064d430f104csi6871795pfr.206.2023.05.23.20.15.41; Tue, 23 May 2023 20:15:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=lvWQ23Bp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239288AbjEXDOI (ORCPT + 99 others); Tue, 23 May 2023 23:14:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239114AbjEXDNl (ORCPT ); Tue, 23 May 2023 23:13:41 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB9E7E42 for ; Tue, 23 May 2023 20:13:16 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-53eee18a192so366307a12.3 for ; Tue, 23 May 2023 20:13:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684897996; x=1687489996; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+8PHSao7q3toNyfgfjr7peVeEA2aTJ4gzpmYB1pZW+w=; b=lvWQ23BpbzUGv8Zz9/yKEZdWIMbq0jYsYpCHZ56cKx0kJhaKWwF205CnjY3IkxCCJr iu3xlmzbS5NbILPOR4ghiN6amtNLE7rfOQxfT9kCTsZrrsCJzDh4sAs/ZmKS1YVHNBDV sQRAARUoLgmmXZFaKaL2+iGAblKqu8h4nUjiL0a/LccDoj0hZJPvCS5mDR4hdvex/u29 abdcRkd8015H8mVC8SwPJkU6PqpbrDecMAQ2ablZP0Mo3e/MNE1M7EHu0R3BYqQ3TyfM 6Px2inQsZ8JWLtKaWJZJE7A+4FIV92vW425mtC8QbsKsDRhq5FEi00jIUGXn7tYZyiB2 nglw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684897996; x=1687489996; h=content-transfer-encoding:mime-version: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=+8PHSao7q3toNyfgfjr7peVeEA2aTJ4gzpmYB1pZW+w=; b=EogaJBohmdpMPEHUZ40snyEgV3lOUb/TfIYnDRPLah4/OJppaYodbHWdg4vlV4hOXr lOqPyaI/Glu6LWc9JrTspPLazpjxa1t7j0ErVy3by9ldzGS1iU2Y7L/h/bAcxKErSc9/ iH4UgKmRfDJ8oIamQO8pUZ4wVNxiFESy32ZDnnWY2XWvFmK4LBqCVkW7o1CR5NRSv7o7 bve/cqeMCo94QmLBbnNYaB7U6BnN4my2eHvwXknF3TUn6K+hSG2XGwOl+Qkcyuf7bljj OGF6ukjS5ZgD2kOPY9XgI90tUUG5QdJS6sgeb2Cy3yHdK6ths2D6A6iOBdsJnYkJO8AJ ajHA== X-Gm-Message-State: AC+VfDxaljauu6F9nlhurcjsWmSsFd+Urp+M5GiraEL3XRGEAvqUi6f+ bNC4m7zxoa6g22y4nove8fx5Ug== X-Received: by 2002:a17:902:ecd0:b0:1a1:b3bb:cd5b with SMTP id a16-20020a170902ecd000b001a1b3bbcd5bmr16741760plh.62.1684897995955; Tue, 23 May 2023 20:13:15 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.249]) by smtp.gmail.com with ESMTPSA id i4-20020a17090332c400b001ab061e352bsm7480769plr.195.2023.05.23.20.13.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 May 2023 20:13:15 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH v4 01/10] maple_tree: Rework mtree_alloc_{range,rrange}() Date: Wed, 24 May 2023 11:12:38 +0800 Message-Id: <20230524031247.65949-2-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230524031247.65949-1-zhangpeng.00@bytedance.com> References: <20230524031247.65949-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766743766991919786?= X-GMAIL-MSGID: =?utf-8?q?1766743766991919786?= Use mas_empty_area{_rev}() to refactor mtree_alloc_{range,rrange}() Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 57 +++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 4eb220008f72..96d102d60b4e 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -6493,31 +6493,33 @@ int mtree_alloc_range(struct maple_tree *mt, unsigned long *startp, { int ret = 0; - MA_STATE(mas, mt, min, min); + MA_STATE(mas, mt, 0, 0); if (!mt_is_alloc(mt)) return -EINVAL; if (WARN_ON_ONCE(mt_is_reserved(entry))) return -EINVAL; - if (min > max) - return -EINVAL; - - if (max < size) - return -EINVAL; - - if (!size) - return -EINVAL; - mtree_lock(mt); retry: - mas.offset = 0; - mas.index = min; - mas.last = max - size + 1; - ret = mas_alloc(&mas, entry, size, startp); + ret = mas_empty_area(&mas, min, max, size); + if (ret) + goto unlock; + + mas_insert(&mas, entry); + /* + * mas_nomem() may release the lock, causing the allocated area + * to be unavailable, so try to allocate a free area again. + */ if (mas_nomem(&mas, gfp)) goto retry; + if (mas_is_err(&mas)) + ret = xa_err(mas.node); + else + *startp = mas.index; + +unlock: mtree_unlock(mt); return ret; } @@ -6529,28 +6531,33 @@ int mtree_alloc_rrange(struct maple_tree *mt, unsigned long *startp, { int ret = 0; - MA_STATE(mas, mt, min, max - size + 1); + MA_STATE(mas, mt, 0, 0); if (!mt_is_alloc(mt)) return -EINVAL; if (WARN_ON_ONCE(mt_is_reserved(entry))) return -EINVAL; - if (min > max) - return -EINVAL; - - if (max < size - 1) - return -EINVAL; - - if (!size) - return -EINVAL; - mtree_lock(mt); retry: - ret = mas_rev_alloc(&mas, min, max, entry, size, startp); + ret = mas_empty_area_rev(&mas, min, max, size); + if (ret) + goto unlock; + + mas_insert(&mas, entry); + /* + * mas_nomem() may release the lock, causing the allocated area + * to be unavailable, so try to allocate a free area again. + */ if (mas_nomem(&mas, gfp)) goto retry; + if (mas_is_err(&mas)) + ret = xa_err(mas.node); + else + *startp = mas.index; + +unlock: mtree_unlock(mt); return ret; } From patchwork Wed May 24 03:12:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 98258 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2564857vqo; Tue, 23 May 2023 20:16:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6kZxKxInROtYVfpUSxHO67xNLH2JQPzUJLKwDmD0wim0y4fFGLL8gNik9OxbnkfSX+1dpy X-Received: by 2002:a17:902:ec86:b0:1a6:a8e5:9240 with SMTP id x6-20020a170902ec8600b001a6a8e59240mr17819776plg.4.1684898173209; Tue, 23 May 2023 20:16:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684898173; cv=none; d=google.com; s=arc-20160816; b=p2WRSlIs3hKu04PXe8mxD/3LTzkCbFy1ecvtYwvcueBTE6/ywaMnjFjqGEYQnVxnxX Buw6UhNtgOT8RzUQf+jewLM1OsY/qwawpduk0WmVSaioZ1zctu054UTidgHRGiYGXjg6 8t2yYA74WVhOXkQEh8QlmZeGY2lDOVTGBB7v8i9JPxoTtZzHoyf9gqTwDv7z5cxWJaGO A1SrGXksZMG1DjDWbnfCj0nlkOvObPiRHCbOUFMOg6F9LoG2rtu/5Okf2Mu5i0sNTFGs w+8FkgTsXdt56aYxPuKkaPwmnkQSsqU1EQtzH2onGF6rjRHCLA66k8jYVcHWrtzyntPV +3Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ckt2ag3ZoF3mgkuxNjyDxYjsZDgVbwKu3RW+Fb2CiD0=; b=0zd6AvOZm5cM4o7WqRmpSzQ80nsqWOQtUScTStvkk+7SRwtThZyb6ZCr5W9dlgluiU zaQvgMzlVNTjJjx/sYlCvX6fhG1ACVwE989LoVDIzBeyM6Kh8W+EzhOU5gjtomMPcQ7L OahWyzQFd3/yyA26JdCM/RMT9voqG/uhEL13U6sRUjlLBy4cpBlhXmS3NH0+1FSHkgSJ UItjqTNnJ4rU6o2O+F12AH9vvR15tHdDosBwyl//uRe2+R9HgvQgwOHvmaACA3kvFit5 MbKKXEIpSaIB5QgsxCli9fkYbGDOa4RgHF7jlIiNc6b1AdfvELmtEpvyodIYjuCiWkMy nTgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=R9RNnIEN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j3-20020a170902da8300b001a66c2f479asi1869376plx.219.2023.05.23.20.16.00; Tue, 23 May 2023 20:16:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=R9RNnIEN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239284AbjEXDON (ORCPT + 99 others); Tue, 23 May 2023 23:14:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239296AbjEXDNq (ORCPT ); Tue, 23 May 2023 23:13:46 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 799AAE9 for ; Tue, 23 May 2023 20:13:19 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1ae4be0b1f3so3383245ad.0 for ; Tue, 23 May 2023 20:13:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684897999; x=1687489999; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ckt2ag3ZoF3mgkuxNjyDxYjsZDgVbwKu3RW+Fb2CiD0=; b=R9RNnIENcm151VyqYa/nqwjf1BhewhDeVjq4hnYK2ZCJ9zYTYaDCmfildSu8xlJ29P 87FyT/a7va4k24YfyPPXmQjaWvuZRn47kTxvSRFCr6VnmSc2MtDTqImDn1eMPL8CNoHy cA3eyqxHaCcIxQLKKxtJDN1TLGOrfTooLKwS/4QF73ztb6i7qhrfqyAjaFvdSjm0B1rN UsNuaVxpBWAvHSMVQ1mHnSLHrEYAcgRFS7FQXRgDKwceWjRlB5ov0JaaksFOfmy1TlyX jzd94++aTxMoXfMtaax3HspHd/jL4wyu16QSUWtc3Hs5i0VfMgI3savoY1uOx4KEgXYy uRAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684897999; x=1687489999; h=content-transfer-encoding:mime-version: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=ckt2ag3ZoF3mgkuxNjyDxYjsZDgVbwKu3RW+Fb2CiD0=; b=lUnd/uyqUU7QuG4jZJlMWh8V5RGFYD0HrMVtHN7J8or3WtAuzXcjveSsY5FwQc87W1 8+yCKkZITyBRJsxKqkYbFtSK9BkwBDOtD5FgN6BQoFlI0E2mD7Lcv8eTxP5w6LCfDmNS ndvKddvjABSt2Ouwh862o8613fCBJY7DNUnrcWBnMAZn1gh9Nivs7hvetVShPuTLW0AZ jDJ88ksDvDodSTnG+a5ykmszpguoqcT+DjeTysjP10CUbeyGEhlO/4RfmenCFn9r0Mtt IbY+k6KhIGX+Ygm/ZedO87beqR2MljvmGgTsxlmIVpv4aHCA6fiLVhtMFdjFR5DKz6Z6 F3hQ== X-Gm-Message-State: AC+VfDwVkN+gs6QTCpiFrGBIgEu9a/FLIOCrzoIhYgR3a4k5JTdcntWt z0FZtB6Vh2R9VJhfDSFiNmbMew== X-Received: by 2002:a17:902:bf06:b0:1ab:1bdd:b307 with SMTP id bi6-20020a170902bf0600b001ab1bddb307mr13560839plb.51.1684897998911; Tue, 23 May 2023 20:13:18 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.249]) by smtp.gmail.com with ESMTPSA id i4-20020a17090332c400b001ab061e352bsm7480769plr.195.2023.05.23.20.13.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 May 2023 20:13:18 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH v4 02/10] maple_tree: Drop mas_{rev_}alloc() and mas_fill_gap() Date: Wed, 24 May 2023 11:12:39 +0800 Message-Id: <20230524031247.65949-3-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230524031247.65949-1-zhangpeng.00@bytedance.com> References: <20230524031247.65949-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766743786587407660?= X-GMAIL-MSGID: =?utf-8?q?1766743786587407660?= mas_{rev_}alloc() and mas_fill_gap() are no longer used, delete them. Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 108 ----------------------------------------------- 1 file changed, 108 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 96d102d60b4e..263bd0ccc31b 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -5120,46 +5120,6 @@ static inline void mas_awalk(struct ma_state *mas, unsigned long size) } } -/* - * mas_fill_gap() - Fill a located gap with @entry. - * @mas: The maple state - * @entry: The value to store - * @slot: The offset into the node to store the @entry - * @size: The size of the entry - * @index: The start location - */ -static inline void mas_fill_gap(struct ma_state *mas, void *entry, - unsigned char slot, unsigned long size, unsigned long *index) -{ - MA_WR_STATE(wr_mas, mas, entry); - unsigned char pslot = mte_parent_slot(mas->node); - struct maple_enode *mn = mas->node; - unsigned long *pivots; - enum maple_type ptype; - /* - * mas->index is the start address for the search - * which may no longer be needed. - * mas->last is the end address for the search - */ - - *index = mas->index; - mas->last = mas->index + size - 1; - - /* - * It is possible that using mas->max and mas->min to correctly - * calculate the index and last will cause an issue in the gap - * calculation, so fix the ma_state here - */ - mas_ascend(mas); - ptype = mte_node_type(mas->node); - pivots = ma_pivots(mas_mn(mas), ptype); - mas->max = mas_safe_pivot(mas, pivots, pslot, ptype); - mas->min = mas_safe_min(mas, pivots, pslot); - mas->node = mn; - mas->offset = slot; - mas_wr_store_entry(&wr_mas); -} - /* * mas_sparse_area() - Internal function. Return upper or lower limit when * searching for a gap in an empty tree. @@ -5307,74 +5267,6 @@ int mas_empty_area_rev(struct ma_state *mas, unsigned long min, } EXPORT_SYMBOL_GPL(mas_empty_area_rev); -static inline int mas_alloc(struct ma_state *mas, void *entry, - unsigned long size, unsigned long *index) -{ - unsigned long min; - - mas_start(mas); - if (mas_is_none(mas) || mas_is_ptr(mas)) { - mas_root_expand(mas, entry); - if (mas_is_err(mas)) - return xa_err(mas->node); - - if (!mas->index) - return mas_pivot(mas, 0); - return mas_pivot(mas, 1); - } - - /* Must be walking a tree. */ - mas_awalk(mas, size); - if (mas_is_err(mas)) - return xa_err(mas->node); - - if (mas->offset == MAPLE_NODE_SLOTS) - goto no_gap; - - /* - * At this point, mas->node points to the right node and we have an - * offset that has a sufficient gap. - */ - min = mas->min; - if (mas->offset) - min = mas_pivot(mas, mas->offset - 1) + 1; - - if (mas_is_err(mas)) - return xa_err(mas->node); - - if (mas->index < min) - mas->index = min; - - mas_fill_gap(mas, entry, mas->offset, size, index); - return 0; - -no_gap: - return -EBUSY; -} - -static inline int mas_rev_alloc(struct ma_state *mas, unsigned long min, - unsigned long max, void *entry, - unsigned long size, unsigned long *index) -{ - int ret = 0; - - ret = mas_empty_area_rev(mas, min, max, size); - if (ret) - return ret; - - if (mas_is_err(mas)) - return xa_err(mas->node); - - if (mas->offset == MAPLE_NODE_SLOTS) - goto no_gap; - - mas_fill_gap(mas, entry, mas->offset, size, index); - return 0; - -no_gap: - return -EBUSY; -} - /* * mte_dead_leaves() - Mark all leaves of a node as dead. * @mas: The maple state From patchwork Wed May 24 03:12:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 98259 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2564954vqo; Tue, 23 May 2023 20:16:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7nQt2ylUIhLl79hqiGqod5x0fmwUXCK4pbi66BPGOOWRQLfomDGKKpL/MyqR3eCP1HNRrb X-Received: by 2002:a17:902:e746:b0:1af:bbfd:1c07 with SMTP id p6-20020a170902e74600b001afbbfd1c07mr7624039plf.57.1684898193919; Tue, 23 May 2023 20:16:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684898193; cv=none; d=google.com; s=arc-20160816; b=e2tZbjtP/UODWx6qA/S3Lw73fPgbziJrSgT/zBx1LdUVSz27QmRcKLsp0qKWg0LA5l 3AQ79bGGUzHtd3xjsVBajlvgXjg+X5I7RWx9s+l3J1CsagojpNVhKZsOq1+84e9L/nfJ futVxzopVojdWEVPx1QC2U6bI38e/cYgJLhOb+U8Hq4MGZAkIkqSqJy4+A+Ad6Y7Xz7H aboIgDv/IKyrMpuMRWH80k7YbVAcU+AZLnpjVxnrGIWm/uhaT0ZsRtvmbhHEoxHJ1lhn 35giRhxeCUEK4aqrKtsN60aekLsGjIo0NQjWyoXZ9IHIjSk+yq/rUQdo2gpjBVKc9kYI YlTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EQslJb4TTQ6f3QnMShcvH80xJECcy+dWiloGaRtjezU=; b=NJPPH+XoZca7aH6+YmjCTRIIn54wOXq/fbk6/xW6D4eUkQEO0Fui8PlDUcWgnusH9J e2VUmlsFJHDnRrpMLb8COgP948bodn/a30oJFbr4LYqUMKWS9s4XkI3SzHN1GGbc+W/1 RcRIGTRQsmcSFnPpIWZaLCYI94qNZe8woZv32JIJ0JnFLlf0hL/LA4Ra7M4ZwUOamOO2 4gn1K+zy7bWwwIegq7yHlPStKepvnbBm9JdcyX20Zzf6rkEL8TgfCzZB54Q5JnfK7x5o goZR/nncasc6K2QF8XL/zpOGthIUbeLJI5xNKeIN+7bT75c+4KvmfGYo3FCPepA5A19U 5Q5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="i5/jXr97"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x18-20020a17090300d200b001aad6d5f016si4623528plc.536.2023.05.23.20.16.20; Tue, 23 May 2023 20:16:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="i5/jXr97"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239356AbjEXDOV (ORCPT + 99 others); Tue, 23 May 2023 23:14:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239306AbjEXDNu (ORCPT ); Tue, 23 May 2023 23:13:50 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 413BD196 for ; Tue, 23 May 2023 20:13:22 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1ae3f6e5d70so4043985ad.1 for ; Tue, 23 May 2023 20:13:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684898001; x=1687490001; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EQslJb4TTQ6f3QnMShcvH80xJECcy+dWiloGaRtjezU=; b=i5/jXr97UIsdHU5etmogFyDj7C2w+qodiIstyuPmozbpYtvlWbpyrBC35aIkuQPKWz T48K+vdaW1bxGnZvnRg3yusdz1FeUyYztH5umoQf7+8NEMw4B70AsUa9lwjGJYLS1KMr 5Ak8I4VJpurMBrvbJKEHCdlTz2Ij4qCE92GL/Kr/B+XuVl/EtInaS5I7YIVMjD/yRqwM 26dxR3Xnoyt5A9f+asTG065uQc/ezFzj/1eGgwED/64LZk6iQWjVzpyw/nwBX0xtIa8h rnd7xldyaw6azZ//jr318c0sorc90X5wtNPgLeeRyjjuIuzWAOFrLzqSi4N2GmqsSyxO wRkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684898001; x=1687490001; h=content-transfer-encoding:mime-version: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=EQslJb4TTQ6f3QnMShcvH80xJECcy+dWiloGaRtjezU=; b=XsNWVHMSygtFNT/Z3AvPOOn5VwW3CYjRFka5KHmMzn8okoD3rGCKyxF+LZVjxH1pau yBgbegB6TquMc8C1dZ902YT3UqsCVae4bmmhF/QRmnu+XZ9NHyjG9hhpfSonXndbPlOx MxKkNpdZDg1eP79WOerwcEx9OzB6cfUoiVbdBIfTF+HDXKhuSuqnKL7UHRgtaPvXa0qY MeSUlbrOl2YcxnrGtinuG0sT+sCnFdJAbiyss2h26TfopgrRRvcBbu6s/xixDspG9l1t aFOLjQPW2iISjLWcvvyIvPZly7cuJa+maGoeWjjnSqHWBZbarQHlEqr/9BIs5GlNSfip Kkug== X-Gm-Message-State: AC+VfDwbduP9izKJlwQrwy4ECCmgdN8GTzznWdg5tDrdBHdZhHyQeK03 2WBotzMZbAWMpCSvvXScI96jqA== X-Received: by 2002:a17:903:11c9:b0:1ac:750e:33d5 with SMTP id q9-20020a17090311c900b001ac750e33d5mr21405280plh.15.1684898001677; Tue, 23 May 2023 20:13:21 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.249]) by smtp.gmail.com with ESMTPSA id i4-20020a17090332c400b001ab061e352bsm7480769plr.195.2023.05.23.20.13.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 May 2023 20:13:21 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH v4 03/10] maple_tree: Fix the arguments to __must_hold() Date: Wed, 24 May 2023 11:12:40 +0800 Message-Id: <20230524031247.65949-4-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230524031247.65949-1-zhangpeng.00@bytedance.com> References: <20230524031247.65949-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766743808137408269?= X-GMAIL-MSGID: =?utf-8?q?1766743808137408269?= Fix the arguments to __must_hold() to make sparse work. Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 263bd0ccc31b..3fe6a6685384 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1752,7 +1752,7 @@ static inline void mas_adopt_children(struct ma_state *mas, * leave the node (true) and handle the adoption and free elsewhere. */ static inline void mas_replace(struct ma_state *mas, bool advanced) - __must_hold(mas->tree->lock) + __must_hold(mas->tree->ma_lock) { struct maple_node *mn = mas_mn(mas); struct maple_enode *old_enode; @@ -1792,7 +1792,7 @@ static inline void mas_replace(struct ma_state *mas, bool advanced) * @child: the maple state to store the child. */ static inline bool mas_new_child(struct ma_state *mas, struct ma_state *child) - __must_hold(mas->tree->lock) + __must_hold(mas->tree->ma_lock) { enum maple_type mt; unsigned char offset; @@ -6204,7 +6204,7 @@ EXPORT_SYMBOL_GPL(mas_erase); * Return: true on allocation, false otherwise. */ bool mas_nomem(struct ma_state *mas, gfp_t gfp) - __must_hold(mas->tree->lock) + __must_hold(mas->tree->ma_lock) { if (likely(mas->node != MA_ERROR(-ENOMEM))) { mas_destroy(mas); From patchwork Wed May 24 03:12:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 98262 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2567891vqo; Tue, 23 May 2023 20:26:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4nPTEFuIP2RQLvUWmQ/BWuyyjITioNIR7FCYNmuTPM005T1oGH6AlItsdX/aI6v8o8kgk0 X-Received: by 2002:a17:90a:1548:b0:24b:52cb:9a31 with SMTP id y8-20020a17090a154800b0024b52cb9a31mr20868815pja.22.1684898765047; Tue, 23 May 2023 20:26:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684898765; cv=none; d=google.com; s=arc-20160816; b=r8ipghVeutHISIf7tJwzpeYORN8mZ2SSZqGzP9WlIsAuSBGI3yHQiyAPWe1+jYCA6U cVf2PEz2g/MGES7wb8TflmG4/mnCCJF/JXwEroej0J72fO4K+6dX7BN8Fvktw+FI8UzQ LZYthtX7YR/FfCRp5rwS8lnTQ8MKFZXF/6Jh2WbLre7VOiUM5N8t5mdXmIn5ZyGk3wqR 82cFCbhHTABeyrQ+STxPs37MAaqiXqrKlekfWoLmeKkd697NvF8JJtr1ZWMFcHkDfnQ3 vFwxPhqdg0PjJ199YwQvFjT8FtZC51JlFP3k09Mzyfyp2Y4F6VDkzuMK1EZRppOAfkbe UMmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=E5ruzeEGnj5CNT1/L3jtI3wslKiej4m4uvmLFSF+fv0=; b=FfpwFehF9SHgxli0SPeajuBtJ9eyt9PrHhsxSSTthBAqXVwCp3uaLjqxFMPIoA1Dzq ol8pHtBflTco0PVkt6kPBDbHhuRWEuPZ2HJPuEIIdBwoSQYgPXW0Oi9kjE3pdtxZq2eR Z8rGCwsprWcSnO+J1gtB7/g41F8IPjd4VJTha4E9mZ7Dfpd68RyQmf/SnNBqXLZdfD/N JP9kqCB8huoa/o+9EjsNCDhKQtOsokW4dek8ax6LzwTm41K8WugCfw3sBpLiBU0GGWln 8fL0peY5kyTNxpsbfBXlhVHuNLP7WSMko09xqKXEHCQpAZGak8iqn6yX4AsodVOsa+hJ 2tUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="MAXMrwd/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bo24-20020a17090b091800b0023fb875a929si489060pjb.106.2023.05.23.20.25.51; Tue, 23 May 2023 20:26:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="MAXMrwd/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239359AbjEXDOZ (ORCPT + 99 others); Tue, 23 May 2023 23:14:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239092AbjEXDNx (ORCPT ); Tue, 23 May 2023 23:13:53 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28F241A8 for ; Tue, 23 May 2023 20:13:25 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1ae507af2e5so5242605ad.1 for ; Tue, 23 May 2023 20:13:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684898004; x=1687490004; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=E5ruzeEGnj5CNT1/L3jtI3wslKiej4m4uvmLFSF+fv0=; b=MAXMrwd/Xszur0x1fVAw7betXZi6Nv6iEeLRVE5rWFKAKqojhanpmq36+yY3jJQzsO M9EaO7RCl07OPXG4T0XWZ9VSsKYxu0A23zt5ExwuJrHR4zwdz4j0AmGa1VSOUMO6wVYw qbhvNZyU6dI9n7coOrUlXhim1BD85Jo0/sUOOUpXURBnyIkhz77RCwKkEwgBBXh8yi4h lupqDHDCc8iRhYj0YQ6830133yOLFDVOMIx7nBBQEQIABrD38VhOK6s7jpcSWBsQBTYP IV1HaE09ZjaHvHuTj90fgQdS2QStLY/pP/3jhoEO7eVxczLOyNTW1OWsR4ZkoGp1yHNJ r9VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684898004; x=1687490004; h=content-transfer-encoding:mime-version: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=E5ruzeEGnj5CNT1/L3jtI3wslKiej4m4uvmLFSF+fv0=; b=YeVJfpPONlXVggjy3g/CYnrqSQb+3CSAVWNzRfrInqiGhzURPaPXoEvVqF0PVsEEzE yz2EYT1ycmvd/i+sYpDfdBAgXRt4UBw6AHDo69/2Df3ohrmuA8jtXiuztrzICdMaYg6u BSI7/Fq+h1/QQleGdLaxjxLRoPRYtEDH30kTvBaKRn9BN5KeIIWuXNE7orbRDo3zuqBf ole5ekEAMWu+iwaARNEWwNTap4klz53/kWLqFxEZ8hK5yKeP7X3du4itoGLNW0P1k+Gw UUtGfGUNqG6vW5VjNEnXfz3Gskot8KH6OmJl7ZaqLFjxjlxddPYllvNryTqlTKIA7lfX FbAA== X-Gm-Message-State: AC+VfDxdAK16IVcw7d32HVSBYEmNtn3GGvQI0RFwDjdhLN1lxNEy1/Rz pAMUonppNFm6GWRPyMtuhaXscWZGIlsxmYl52aY= X-Received: by 2002:a17:903:8c4:b0:1ac:b03c:a58e with SMTP id lk4-20020a17090308c400b001acb03ca58emr20956735plb.25.1684898004536; Tue, 23 May 2023 20:13:24 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.249]) by smtp.gmail.com with ESMTPSA id i4-20020a17090332c400b001ab061e352bsm7480769plr.195.2023.05.23.20.13.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 May 2023 20:13:24 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH v4 04/10] maple_tree: Simplify mas_is_span_wr() Date: Wed, 24 May 2023 11:12:41 +0800 Message-Id: <20230524031247.65949-5-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230524031247.65949-1-zhangpeng.00@bytedance.com> References: <20230524031247.65949-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766744407225390054?= X-GMAIL-MSGID: =?utf-8?q?1766744407225390054?= Make the code for detecting spanning writes more concise. Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 3fe6a6685384..41a105e76e22 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3728,43 +3728,31 @@ static inline void mas_store_root(struct ma_state *mas, void *entry) */ static bool mas_is_span_wr(struct ma_wr_state *wr_mas) { - unsigned long max; + unsigned long max = wr_mas->r_max; unsigned long last = wr_mas->mas->last; - unsigned long piv = wr_mas->r_max; enum maple_type type = wr_mas->type; void *entry = wr_mas->entry; - /* Contained in this pivot */ - if (piv > last) + /* Contained in this pivot, fast path */ + if (last < max) return false; - max = wr_mas->mas->max; - if (unlikely(ma_is_leaf(type))) { - /* Fits in the node, but may span slots. */ + if (ma_is_leaf(type)) { + max = wr_mas->mas->max; if (last < max) return false; + } - /* Writes to the end of the node but not null. */ - if ((last == max) && entry) - return false; - + if (last == max) { /* - * Writing ULONG_MAX is not a spanning write regardless of the - * value being written as long as the range fits in the node. + * The last entry of leaf node cannot be NULL unless it is the + * rightmost node (writing ULONG_MAX), otherwise it spans slots. */ - if ((last == ULONG_MAX) && (last == max)) - return false; - } else if (piv == last) { - if (entry) - return false; - - /* Detect spanning store wr walk */ - if (last == ULONG_MAX) + if (entry || last == ULONG_MAX) return false; } - trace_ma_write(__func__, wr_mas->mas, piv, entry); - + trace_ma_write(__func__, wr_mas->mas, wr_mas->r_max, entry); return true; } From patchwork Wed May 24 03:12:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 98265 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2573327vqo; Tue, 23 May 2023 20:43:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7IadNogXx6Koi9tOItQRocNbyadrQ+eNoBTG5KPXb2j8HUg8YcEn9g2GDGjnx4bp8IZpna X-Received: by 2002:a17:90a:a6f:b0:252:bb8d:3dce with SMTP id o102-20020a17090a0a6f00b00252bb8d3dcemr15326827pjo.39.1684899837610; Tue, 23 May 2023 20:43:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684899837; cv=none; d=google.com; s=arc-20160816; b=bBEo5e92bbyhfWUKK0ZmRDEqiA6C0qEoRhjwb1DYNDV6fFHo0wqrMbF7BgOTZ0sYge wKIg0LKMcnlZbuRw+/DSal7/fzFMD5F/osPIZtwabZ4bzC4zmW0Kp+a9c4COgvf2ryx9 3vPc1KZDTXufhxHdY2LnqC1YrlTGSJuEjTRl+pSOhxjU6ACg1/kRnP/Ta2SWPn/GPe1+ x0YBb+dZCPEvY4WzacD9/I0OwXS/giMMi3Fr/26sCUWSK17FbV0k7DdLWNtIm4gqFI6d uwq26Oah79TfvkZsL2J0hsLNzEsynHMKBtDfaw0yzeIbKbFqYE/29/iwqUrropdxpnLj k3rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ho+8AxwCMUO1UZDPlZ+RxzprWSmT0wiRibYRYtQid4k=; b=aifLm3bVtcdetEwlR7BA1TLLolipIFtQT/HCwe9i6/GUfOCRhVlDa8e9YBZnTIUrrw 4OOvFwBCEuPU9rEJ0o+xIq4NPJ6AW/GdHdR7Bl8IZjItGSxC1De0+ctxr8bjeAbHTlBl Ol6KSXL6vfQ9YIB66TWFS0xetuSBhZMiO5ljtxZNmYVJWh5dEdyJTiPs2wdrTXF1yzRK dULL/zXMJbs4PsyTHfnyU4nkAQdHmp2cTNqD7rhPbYt91jS/wW5HY/M8i7lZvJ1pxZf+ IW/O9i5T/co6NA4c4Oduf9oTsQJZ9Ygyo5G4zzlTg01dRWzYcQymRpKcb89mxqzZO+xC VF6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=kvoX8rfQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bg7-20020a17090b0d8700b002537224e05esi534274pjb.62.2023.05.23.20.43.45; Tue, 23 May 2023 20:43:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=kvoX8rfQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239304AbjEXDNu (ORCPT + 99 others); Tue, 23 May 2023 23:13:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239279AbjEXDNf (ORCPT ); Tue, 23 May 2023 23:13:35 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBEE9E54 for ; Tue, 23 May 2023 20:13:27 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1ae4c5e12edso3553435ad.3 for ; Tue, 23 May 2023 20:13:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684898007; x=1687490007; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ho+8AxwCMUO1UZDPlZ+RxzprWSmT0wiRibYRYtQid4k=; b=kvoX8rfQyN2AB0Gr43+8rZLVHFEmrrDTqutZAx5YmjW/kGuQGJ0PYvltnv5oe+C2Dz 5qJCza00ybILWo0O75SnzamE/deaG5NaRNh5OG1IFwsc87i9gFW9INu037TjJF1yAJNr iKqeDs5Fp+AscJaCq4eKX+NBdfovr1pTO1C+zYi0UA+vOAW7Uvs4emRsWyygLkp27mAF Fbpqj8PxnSGvAO2m8iSuM2zxRZIZL0nARH7uV4WpbZ5mrUUSxTHDwmBAevUUz6oEWcPc IrnFnja7kLA1sl5ZZz0CUVqI6joBnhibcFuTnaVKHI+e0tnVt9HoS5U4VDbwvQOLyBDy AVAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684898007; x=1687490007; h=content-transfer-encoding:mime-version: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=ho+8AxwCMUO1UZDPlZ+RxzprWSmT0wiRibYRYtQid4k=; b=GrilAXFPEmLJMdshvD6+IT5nGfwZ5n+sF45Ycpic/wJJS9aihtu2IhOsuW9q5JjJYa cEEQ1CfN50yKBG0iqQczzfT8wtOJx3ygmJvQhi0H/xPPDzS987Fs1mF6bsjTAlFiTD04 EJUvVgYd1k+T/k0ZZRORqoBpm7pGitmU4Vas0xOn4+FPQn4w+vDYHPoK7azfrAiTCPQi Ih6UmqJTYA3a0UNEyZn6JInKb8uySI4JYq+uGw2qXfm79mHKQDVnEDmyV0gzRecTW6X+ 2qSJNc+JbINxRCUMfr/x+mwUQEXfT/PZ5NK/12fh4mchnpYGKt1mN2skRvHuztaoh967 QSXg== X-Gm-Message-State: AC+VfDyQuF9jnSZBtr9j3zdC/F5QF2I4nUCJHr5Vl+PcqgyONHLgfwOL bBX4ETpFl3bA3IUvtsOj028mRg== X-Received: by 2002:a17:903:2287:b0:1ad:b5f4:dfd5 with SMTP id b7-20020a170903228700b001adb5f4dfd5mr19242735plh.32.1684898007229; Tue, 23 May 2023 20:13:27 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.249]) by smtp.gmail.com with ESMTPSA id i4-20020a17090332c400b001ab061e352bsm7480769plr.195.2023.05.23.20.13.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 May 2023 20:13:27 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH v4 05/10] maple_tree: Make the code symmetrical in mas_wr_extend_null() Date: Wed, 24 May 2023 11:12:42 +0800 Message-Id: <20230524031247.65949-6-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230524031247.65949-1-zhangpeng.00@bytedance.com> References: <20230524031247.65949-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766745532248658944?= X-GMAIL-MSGID: =?utf-8?q?1766745532248658944?= Just make the code symmetrical to improve readability. Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 41a105e76e22..e6e42e1ba44c 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4264,19 +4264,21 @@ static inline void mas_wr_extend_null(struct ma_wr_state *wr_mas) { struct ma_state *mas = wr_mas->mas; - if (mas->last < wr_mas->end_piv && !wr_mas->slots[wr_mas->offset_end]) + if (!wr_mas->slots[wr_mas->offset_end]) { + /* If this one is null, the next and prev are not */ mas->last = wr_mas->end_piv; - - /* Check next slot(s) if we are overwriting the end */ - if ((mas->last == wr_mas->end_piv) && - (wr_mas->node_end != wr_mas->offset_end) && - !wr_mas->slots[wr_mas->offset_end + 1]) { - wr_mas->offset_end++; - if (wr_mas->offset_end == wr_mas->node_end) - mas->last = mas->max; - else - mas->last = wr_mas->pivots[wr_mas->offset_end]; - wr_mas->end_piv = mas->last; + } else { + /* Check next slot(s) if we are overwriting the end */ + if ((mas->last == wr_mas->end_piv) && + (wr_mas->node_end != wr_mas->offset_end) && + !wr_mas->slots[wr_mas->offset_end + 1]) { + wr_mas->offset_end++; + if (wr_mas->offset_end == wr_mas->node_end) + mas->last = mas->max; + else + mas->last = wr_mas->pivots[wr_mas->offset_end]; + wr_mas->end_piv = mas->last; + } } if (!wr_mas->content) { From patchwork Wed May 24 03:12:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 98260 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2565415vqo; Tue, 23 May 2023 20:17:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Xa6VUq6V0/Xfn1fwZcmnY9Xc/gaXe5awochaV5QiibFEap8NxPWEm2sPl649Q1+48F4vD X-Received: by 2002:a17:902:7d8d:b0:1aa:d971:4623 with SMTP id a13-20020a1709027d8d00b001aad9714623mr13759503plm.38.1684898274547; Tue, 23 May 2023 20:17:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684898274; cv=none; d=google.com; s=arc-20160816; b=QCg252E0fIg37L+7qtxYJQQb0+hpHm8jUI22n+RO4XKSR6M4XE8J/pUSLo4cPV5ejf O6EPg2mhpHXUpCNw/0B8vkOYx4r26l/RMjD3QikyhN0EcMnFtNwCd3KF5+PaYUL8YS0e 5mYZ5n3dZb/wNlzB7VFZeSQK217dm6kvP5HyhpuaMiHmqE8i0CchuyZAwAkEykEuAvZz kS5xuV8XkaKqNeDo/XLXhNFpiLvF+SJwIcSreX696MqY/E9gBdFwoZMAzHJLxwsuzx6z R8TbVmumKLLleUCYn4WcUYqItLEC3GEsRHvcI3KegsKuvXT9FqIqaxil7NGqvE2W+H9P WaqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Sfx1V5T4mPIwVqP+RrJR35TgWmrm3iAxbhRMi/Gcd/w=; b=tsPsotIFJdhN43En8qp2BH+dY8/c2gLMZjBLqxotHU+shdwXDmmDWzTkjgoTEPXaRE zw5VH4PiXCulbAq5KLR9ydKFIupGR2X+rIWGxlPwJ1o5UqLVWfzt8ZpTPWJrI3VW1qlo CmNSdKVfqABy+L+hDLN24IeJiYr68zwhou3q7avyUDZLXQVzUXTDNswKzySbNc4LUCwP tI6L0aWtt9MXFYCUEKxM6dkUhBykz0PaQ1a2kocf75Bc70Z4oQpEOil4F7g4H2ex6qEm nC7bJaQnghExX0qEct82KKkrshphn2+JRTdO8jFKyNyItBxYYJGnx+63wlKOU3Z2uTwS ZAvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=JB3kp4BJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jb7-20020a170903258700b001a94b91f412si3165443plb.164.2023.05.23.20.17.42; Tue, 23 May 2023 20:17:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=JB3kp4BJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239109AbjEXDOe (ORCPT + 99 others); Tue, 23 May 2023 23:14:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239233AbjEXDN5 (ORCPT ); Tue, 23 May 2023 23:13:57 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CC21E5C for ; Tue, 23 May 2023 20:13:30 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1ae79528d4dso4255745ad.2 for ; Tue, 23 May 2023 20:13:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684898010; x=1687490010; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Sfx1V5T4mPIwVqP+RrJR35TgWmrm3iAxbhRMi/Gcd/w=; b=JB3kp4BJlOTs+7cy33BIr9gKo327JK5pA7ulU3SsjOpt3OCFJdJD7nK6aH5tKH88dJ rFNBih93HAFSgVUwvO50dFWu8MWGNidvUluFSfNOqUZpHn6gautW+XcY602ivtqiQmOd DHaviW5bqiNIiZr18jVVyRGEvqNQCnp2SPyV9uat+WK4D/AHQ4dwM2H04pC/D3F41xcv gUBrRudDRolPnEB+3e8vALOAFWlf6PovASzbMUtuHxm32FFhN4tq1uzAtRRQKIOo2+Fc En7/cwMNU5GHxKFqTz8+PyPf7Md0NP/OSjUlmMq5pNdNop7bHIIHzPJ4YWnVZKtXiwBL rHpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684898010; x=1687490010; h=content-transfer-encoding:mime-version: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=Sfx1V5T4mPIwVqP+RrJR35TgWmrm3iAxbhRMi/Gcd/w=; b=CHV3LnFS7WufxRXJcpu4R1oGCX6bTiYFr7EEAIo5x22tCr0PtRrCcyOe03PnpEA4Y6 xzXP/HVJdwUisfC7WAP3Pmuz8NQlTQoYXG//27NpsFTRS4PXbECf7F/0dMSFQ/QkL76+ CXgWPKsmzWpbQJQzP6oqZVyktp8xMqp2oOIhYUvVRdHkdnCd/55wgBXcD884hX9zeOBj fi62S5BqP+A9GPA3J/26pLdTzzxJ3etzRKNBa6ehV4LipuXT6B+PNpYbwMicgCi+1xmm 0i5UWVUku6D9OfNcnQNmdP18PuqqwGPZcXyJWUtAEH/tgihtsAB9hmwmpwEkoM/ApHRa 12jw== X-Gm-Message-State: AC+VfDxm6xkDTXqegm3gwG355X5oc8JrpeCtuDGelE6DCouwLv8rBgSa L6IQupuT7S6GYRmai2f4q25OUg== X-Received: by 2002:a17:903:120b:b0:1a6:d15f:3ce1 with SMTP id l11-20020a170903120b00b001a6d15f3ce1mr19866697plh.34.1684898010071; Tue, 23 May 2023 20:13:30 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.249]) by smtp.gmail.com with ESMTPSA id i4-20020a17090332c400b001ab061e352bsm7480769plr.195.2023.05.23.20.13.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 May 2023 20:13:29 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH v4 06/10] maple_tree: Add mas_wr_new_end() to calculate new_end accurately Date: Wed, 24 May 2023 11:12:43 +0800 Message-Id: <20230524031247.65949-7-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230524031247.65949-1-zhangpeng.00@bytedance.com> References: <20230524031247.65949-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766743893147382182?= X-GMAIL-MSGID: =?utf-8?q?1766743893147382182?= The previous new_end calculation is inaccurate, because it assumes that two new pivots must be added (this is inaccurate), and sometimes it will miss the fast path and enter the slow path. Add mas_wr_new_end() to accurately calculate new_end to make the conditions for entering the fast path more accurate. Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index e6e42e1ba44c..07c5c7afd415 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4296,6 +4296,21 @@ static inline void mas_wr_extend_null(struct ma_wr_state *wr_mas) } } +static inline unsigned char mas_wr_new_end(struct ma_wr_state *wr_mas) +{ + struct ma_state *mas = wr_mas->mas; + unsigned char new_end = wr_mas->node_end + 2; + + new_end -= wr_mas->offset_end - mas->offset; + if (wr_mas->r_min == mas->index) + new_end--; + + if (wr_mas->end_piv == mas->last) + new_end--; + + return new_end; +} + static inline bool mas_wr_append(struct ma_wr_state *wr_mas) { unsigned char end = wr_mas->node_end; @@ -4351,9 +4366,8 @@ static void mas_wr_bnode(struct ma_wr_state *wr_mas) static inline void mas_wr_modify(struct ma_wr_state *wr_mas) { - unsigned char node_slots; - unsigned char node_size; struct ma_state *mas = wr_mas->mas; + unsigned char new_end; /* Direct replacement */ if (wr_mas->r_min == mas->index && wr_mas->r_max == mas->last) { @@ -4363,17 +4377,15 @@ static inline void mas_wr_modify(struct ma_wr_state *wr_mas) return; } - /* Attempt to append */ - node_slots = mt_slots[wr_mas->type]; - node_size = wr_mas->node_end - wr_mas->offset_end + mas->offset + 2; - if (mas->max == ULONG_MAX) - node_size++; - - /* slot and node store will not fit, go to the slow path */ - if (unlikely(node_size >= node_slots)) + /* + * new_end exceeds the size of the maple node and cannot enter the fast + * path. + */ + new_end = mas_wr_new_end(wr_mas); + if (new_end >= mt_slots[wr_mas->type]) goto slow_path; - if (wr_mas->entry && (wr_mas->node_end < node_slots - 1) && + if (wr_mas->entry && (wr_mas->node_end < mt_slots[wr_mas->type] - 1) && (mas->offset == wr_mas->node_end) && mas_wr_append(wr_mas)) { if (!wr_mas->content || !wr_mas->entry) mas_update_gap(mas); From patchwork Wed May 24 03:12:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 98261 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2566209vqo; Tue, 23 May 2023 20:20:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7XUbgzwvQ3ZcRCjVcyTEiDVz6jLaB0htvKL9z5Hh5lVB/uAERjILswauYrvDRP063pXfsS X-Received: by 2002:a05:6a20:1585:b0:104:50ce:297d with SMTP id h5-20020a056a20158500b0010450ce297dmr18386512pzj.40.1684898437930; Tue, 23 May 2023 20:20:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684898437; cv=none; d=google.com; s=arc-20160816; b=WXGjyPZLjFWMvvtGJdt3fJmbEKFVrGncIrYDhd6xfISmU/awEvr/okoZ7UT1BVDMje fxagcKWugemW+CiMWJRcLUpl0q9i0Bh4BME4r99DJau6LoQiKPwr4q7VlOuG7OcG2aLn /6Q8eMio9Hk9D65DheVu28ZQKdiBPxcnR4LTGlZoGseR2ptKSEHnr2cYynOAh7ThCEeZ gO19qh3p50/Qk7iz15ZX9EgKEWl1zLSpkYpzulzrAnxsnfQqbNcWm7RwvLE8APfzjYGd y40lH99k1ZPD2mU8tMoqjKTzDHskrvp4UukY9AHbiFX9cbfMOE+hcuoyfT5zuGLq0/EP azrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=z8kX/CacLzRcOeiRpI7Mv6WmATX8iDuuhOGMVtT6UnI=; b=VUZLfkCGw5+K/w10HByV1CSHwzzqqNzOln+LSsI55H9kQIa4AOwkE4cy5mYnoTNBkk d8TyvF2DcXyBJP2Tcd4OvZi9pbdj+BIc80OrpB0NkXbFgctdyDCUAH/LiS9yoqGQhONC 609GeQnj0HB1q6Epgztr2r4Xi8w4QqZMEJeJpKV0aQOmRFUTtD2+WlrSffygp9P3Dssq n7ZMlv44VL3j7ZOEZdFxk03Cmnt3F2dOQBdsEH/78CLPqzRjpWR716OP/yU5nKFa41VV +PGaeTn7KdhOvmyiwQ4BBGJGY/TYxWAiS+ZJBYKKOXo3yxUxRL2OSvl13XIP4e6P65ep fEaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=dAbDkk4G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s199-20020a632cd0000000b005347c4d09dcsi2513669pgs.675.2023.05.23.20.20.25; Tue, 23 May 2023 20:20:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=dAbDkk4G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239316AbjEXDOu (ORCPT + 99 others); Tue, 23 May 2023 23:14:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239287AbjEXDOF (ORCPT ); Tue, 23 May 2023 23:14:05 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAAE4E6C for ; Tue, 23 May 2023 20:13:33 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1ae4be0b1f3so3383935ad.0 for ; Tue, 23 May 2023 20:13:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684898013; x=1687490013; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=z8kX/CacLzRcOeiRpI7Mv6WmATX8iDuuhOGMVtT6UnI=; b=dAbDkk4GiJQU/jxOkINNRJlaXfIOp/R5R+HSQgwpzuH8eiNMPj5AcakWbxo//h8/ay vQ0LArP/qpZgWTAmJpZlCArJFNRl2XkUK6w2jHsLhelCYpaZdm9oTP1m/7V6YEkbfS/8 HyO/Rgus3f3DcI+iFxoHe57XLFmEVK6IDB6Vuy/ehe8mv87fHmjcb1CG4LbntXuhzelG GUw90y//GDnqabcNqlyMLV9Tzj6SLCBwyqtaMmEYllBHBw4OjOeOTJWYzZMRR6xifs+6 GsvQusvycib3LAyIrKaTtOVOZnKOODZ4jt/bPIFoElXPLkj5oRsu0mS/qZKKyYUhYo1G IsRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684898013; x=1687490013; h=content-transfer-encoding:mime-version: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=z8kX/CacLzRcOeiRpI7Mv6WmATX8iDuuhOGMVtT6UnI=; b=Yobs4Xkeghtb0P7pwkgPSsDHpNu1/CqkV6kgg1ITKRjgrbefzbJ75GEa/D+TOLppJP x66o8YAq4P4zkAZUygiPBdjkPP2A72ITiM7/2yzMfTfkZwVo/iHgrZHGGmUNDIbr7JZT wfWQfzz+P+gLIq8Rga4QyYlZmjgD6WqCyvyJ9V54GUiAbo+fB2iQ4tmnmPpIXZi/34m+ 8ewGrGeuIC6I8wxyN9vq5dX8AmlGeGjcXtx7vDCaCzgh+xZjmGf6PjQ7FZqidxNCuCB0 HGTsbCfc30vAhzqFAOJpOyLdVlo2ZTbjxah8gtAZt2i8VAGki+827YT79oIhg7dM44dv +JMQ== X-Gm-Message-State: AC+VfDwIBzRKV3RK0V441hJhXnJf9MSPfaIVUa+Ss45fOg4gIQkaf9YL KuQWFNiQIN7UAQW9wJpE5mSwlg== X-Received: by 2002:a17:902:ec86:b0:1a6:a8e5:9240 with SMTP id x6-20020a170902ec8600b001a6a8e59240mr17812527plg.4.1684898012832; Tue, 23 May 2023 20:13:32 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.249]) by smtp.gmail.com with ESMTPSA id i4-20020a17090332c400b001ab061e352bsm7480769plr.195.2023.05.23.20.13.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 May 2023 20:13:32 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH v4 07/10] maple_tree: Add comments and some minor cleanups to mas_wr_append() Date: Wed, 24 May 2023 11:12:44 +0800 Message-Id: <20230524031247.65949-8-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230524031247.65949-1-zhangpeng.00@bytedance.com> References: <20230524031247.65949-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766744064457060807?= X-GMAIL-MSGID: =?utf-8?q?1766744064457060807?= Add comment for mas_wr_append(), move mas_update_gap() into mas_wr_append(), and other cleanups to make mas_wr_modify() cleaner. Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 07c5c7afd415..676976a005e5 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4311,6 +4311,12 @@ static inline unsigned char mas_wr_new_end(struct ma_wr_state *wr_mas) return new_end; } +/* + * mas_wr_append: Attempt to append + * @wr_mas: the maple write state + * + * Return: True if appended, false otherwise + */ static inline bool mas_wr_append(struct ma_wr_state *wr_mas) { unsigned char end = wr_mas->node_end; @@ -4318,34 +4324,30 @@ static inline bool mas_wr_append(struct ma_wr_state *wr_mas) struct ma_state *mas = wr_mas->mas; unsigned char node_pivots = mt_pivots[wr_mas->type]; - if ((mas->index != wr_mas->r_min) && (mas->last == wr_mas->r_max)) { - if (new_end < node_pivots) - wr_mas->pivots[new_end] = wr_mas->pivots[end]; + if (mas->offset != wr_mas->node_end) + return false; - if (new_end < node_pivots) - ma_set_meta(wr_mas->node, maple_leaf_64, 0, new_end); + if (new_end < node_pivots) { + wr_mas->pivots[new_end] = wr_mas->pivots[end]; + ma_set_meta(wr_mas->node, maple_leaf_64, 0, new_end); + } + if (mas->last == wr_mas->r_max) { + /* Append to end of range */ rcu_assign_pointer(wr_mas->slots[new_end], wr_mas->entry); - mas->offset = new_end; wr_mas->pivots[end] = mas->index - 1; - - return true; - } - - if ((mas->index == wr_mas->r_min) && (mas->last < wr_mas->r_max)) { - if (new_end < node_pivots) - wr_mas->pivots[new_end] = wr_mas->pivots[end]; - + mas->offset = new_end; + } else { + /* Append to start of range */ rcu_assign_pointer(wr_mas->slots[new_end], wr_mas->content); - if (new_end < node_pivots) - ma_set_meta(wr_mas->node, maple_leaf_64, 0, new_end); - wr_mas->pivots[end] = mas->last; rcu_assign_pointer(wr_mas->slots[end], wr_mas->entry); - return true; } - return false; + if (!wr_mas->content || !wr_mas->entry) + mas_update_gap(mas); + + return true; } /* @@ -4385,12 +4387,9 @@ static inline void mas_wr_modify(struct ma_wr_state *wr_mas) if (new_end >= mt_slots[wr_mas->type]) goto slow_path; - if (wr_mas->entry && (wr_mas->node_end < mt_slots[wr_mas->type] - 1) && - (mas->offset == wr_mas->node_end) && mas_wr_append(wr_mas)) { - if (!wr_mas->content || !wr_mas->entry) - mas_update_gap(mas); + /* Attempt to append */ + if (new_end == wr_mas->node_end + 1 && mas_wr_append(wr_mas)) return; - } if ((wr_mas->offset_end - mas->offset <= 1) && mas_wr_slot_store(wr_mas)) return; From patchwork Wed May 24 03:12:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 98264 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2573170vqo; Tue, 23 May 2023 20:43:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6869jK0bUkbzGzW5wdW7onB+HwT0C0fv9ScUVtzrwbhAgnPDYlB7a005VnE3I8r2gJAoZv X-Received: by 2002:a17:90a:282:b0:253:7ddd:d07b with SMTP id w2-20020a17090a028200b002537dddd07bmr14582117pja.14.1684899805789; Tue, 23 May 2023 20:43:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684899805; cv=none; d=google.com; s=arc-20160816; b=gA12s1lw9X5xhU25BwmORIfZkiL3epnImuxbSzUzzmUto0+519r3bCuzACee2l9oS9 TO0V2hcrfAEmYYX9nbdXpCIzS4jbKkM9JtAAZipmrL+34I6pDn35B12Bu8+jkF+3oXFz 7v1RWiunfeiuUDNAK9anCXpqXahinaDIa9OFrdmEj7edMGepk0MJiZfgZYxegczi3GD2 Kj/ZGjdKuVYEo0eT6FjS3D7Kd/X3Gg8A+1ZjtNcyBW3NKncpMkFxiy0IvENRj8diXGMf GRrPvWQk/c/70CJaQIyylcOyrk9vpRwLxDBbS3trf9F+QH4v7gpG3kO43oqCvlo/TfJw iv0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4r/B+P0ZNt0u/JsXVxRA88PA4LS1ywC9VJ4XyQ5w3aw=; b=jolcuBWHMD3H0n1hdiL+B3dF6g1PmJPdKJH2FrTN9jZzSp+mLgYv82NzaoE1DBRXXm tm4A/o+VKV7LoJvgr3EE667VjtKIGKMxhNJ+j4zkgyXfT7HHYeaTmizSfwlUtU6cd+Ve 2oydmj2C1TBGbTS+nIaC+6MOI59fRMS7+Tzsvei8R5VkeYWOyYzyj/iMzfVUg1yiH7vv A03rLVihbHs7Yf4sqKoSd7O+Hn/ygxN3QAVBvbyXxE3REPvMibGaTiEHnRHJHBtri9Tj IJwcEiOx95+iKl3jZDCP+nUcJN79Bnt+XTMseFjA55cx63+5YwXzIuZmK0nZqitXrVOq R07g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=cKaK0PzJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y6-20020a17090a1f4600b00250807ec16dsi514092pjy.97.2023.05.23.20.43.13; Tue, 23 May 2023 20:43:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=cKaK0PzJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239290AbjEXDPG (ORCPT + 99 others); Tue, 23 May 2023 23:15:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239337AbjEXDOK (ORCPT ); Tue, 23 May 2023 23:14:10 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91845E47 for ; Tue, 23 May 2023 20:13:36 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1ae763f9c0bso3588535ad.2 for ; Tue, 23 May 2023 20:13:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684898016; x=1687490016; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4r/B+P0ZNt0u/JsXVxRA88PA4LS1ywC9VJ4XyQ5w3aw=; b=cKaK0PzJJClj7BIIZ9xYrlQhdCx17KGgfoycYEDKN5jEXKpKR6cV6dy46l6VOK1ADK 0IuruPcnO8kruo2u+evuuL/X7ccEK37inNOY2P47BF9uZHhHo1eaAzgmg1V76hoDz2KS XRjqHbwSw/X+izm8dPf9zqZ8jowCvO4nb8SOF+P4tA9/3ku1Of+FpDUMl9Jx82LhyDTK 3TN0i1owLb8gw+gFqvSG/v0sNXQ5AsWP0Rd0gq4N/fWnWYNm3exaJ5f7FZsHTiQQ6CAf eJFaw3mxGwFtw/AK2XXpKo1btbWmrcjCSuREvHhg+QNkXqinuEBJecKgXCvEs3l5RkdC +5nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684898016; x=1687490016; h=content-transfer-encoding:mime-version: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=4r/B+P0ZNt0u/JsXVxRA88PA4LS1ywC9VJ4XyQ5w3aw=; b=hlELB4VwhhPMNJm2/2JDMcIBWxozywjXSpLAEZmLJbPmpH07B1HTO/SoI/l+k/3eNg jZTve5+hAXWXdwbAGKZmT42h7nDq/mKzy52SwVfK3z3oKVSN9Bg3abpVVDej2xnLiNBO loxvb0H2P0Dwngm7H4HHxbaT/0eu5mzRzQa3B3RYpZfRuSgTT5YuYmr7/gqKuMKClV7W 983p3JY/4rkNUtVyYclKl+flh4iwKLTozMQkqwdj2fRgGpj1KaLs3BgPz72/7KbReWi7 Kzkt5xymZh/X8UF91LbqwR84Ftc2hEAJ2+q+UCYfq/+/6+0Rf8UwOpKpCC/DUvDLqrib 5CLw== X-Gm-Message-State: AC+VfDzrcG/ThJBYqhRZE+HmGKQFjKuw1VFuHzKsboZlKvpYQOxa9S1L KDCgcIIEvAbTh6rd0skoGGmnavFjIx/5IcqX0es= X-Received: by 2002:a17:902:f547:b0:1ac:9890:1c49 with SMTP id h7-20020a170902f54700b001ac98901c49mr22348049plf.15.1684898016058; Tue, 23 May 2023 20:13:36 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.249]) by smtp.gmail.com with ESMTPSA id i4-20020a17090332c400b001ab061e352bsm7480769plr.195.2023.05.23.20.13.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 May 2023 20:13:35 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH v4 08/10] maple_tree: Rework mas_wr_slot_store() to be cleaner and more efficient. Date: Wed, 24 May 2023 11:12:45 +0800 Message-Id: <20230524031247.65949-9-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230524031247.65949-1-zhangpeng.00@bytedance.com> References: <20230524031247.65949-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766745498970191299?= X-GMAIL-MSGID: =?utf-8?q?1766745498970191299?= Get whether the two gaps to be overwritten are empty to avoid calling mas_update_gap() all the time. Also clean up the code and add comments. Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 53 +++++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 676976a005e5..1a2b9bb9c014 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4202,49 +4202,34 @@ static inline bool mas_wr_node_store(struct ma_wr_state *wr_mas) static inline bool mas_wr_slot_store(struct ma_wr_state *wr_mas) { struct ma_state *mas = wr_mas->mas; - unsigned long lmax; /* Logical max. */ unsigned char offset = mas->offset; + bool gap = false; - if ((wr_mas->r_max > mas->last) && ((wr_mas->r_min != mas->index) || - (offset != wr_mas->node_end))) + if (wr_mas->offset_end - offset != 1) return false; - if (offset == wr_mas->node_end - 1) - lmax = mas->max; - else - lmax = wr_mas->pivots[offset + 1]; - - /* going to overwrite too many slots. */ - if (lmax < mas->last) - return false; - - if (wr_mas->r_min == mas->index) { - /* overwriting two or more ranges with one. */ - if (lmax == mas->last) - return false; + gap |= !mt_slot_locked(mas->tree, wr_mas->slots, offset); + gap |= !mt_slot_locked(mas->tree, wr_mas->slots, offset + 1); - /* Overwriting all of offset and a portion of offset + 1. */ + if (mas->index == wr_mas->r_min) { + /* Overwriting the range and over a part of the next range. */ rcu_assign_pointer(wr_mas->slots[offset], wr_mas->entry); wr_mas->pivots[offset] = mas->last; - goto done; + } else { + /* Overwriting a part of the range and over the next range */ + rcu_assign_pointer(wr_mas->slots[offset + 1], wr_mas->entry); + wr_mas->pivots[offset] = mas->index - 1; + mas->offset++; /* Keep mas accurate. */ } - /* Doesn't end on the next range end. */ - if (lmax != mas->last) - return false; - - /* Overwriting a portion of offset and all of offset + 1 */ - if ((offset + 1 < mt_pivots[wr_mas->type]) && - (wr_mas->entry || wr_mas->pivots[offset + 1])) - wr_mas->pivots[offset + 1] = mas->last; - - rcu_assign_pointer(wr_mas->slots[offset + 1], wr_mas->entry); - wr_mas->pivots[offset] = mas->index - 1; - mas->offset++; /* Keep mas accurate. */ - -done: trace_ma_write(__func__, mas, 0, wr_mas->entry); - mas_update_gap(mas); + /* + * Only update gap when the new entry is empty or there is an empty + * entry in the original two ranges. + */ + if (!wr_mas->entry || gap) + mas_update_gap(mas); + return true; } @@ -4391,7 +4376,7 @@ static inline void mas_wr_modify(struct ma_wr_state *wr_mas) if (new_end == wr_mas->node_end + 1 && mas_wr_append(wr_mas)) return; - if ((wr_mas->offset_end - mas->offset <= 1) && mas_wr_slot_store(wr_mas)) + if (new_end == wr_mas->node_end && mas_wr_slot_store(wr_mas)) return; else if (mas_wr_node_store(wr_mas)) return; From patchwork Wed May 24 03:12:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 98266 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2573605vqo; Tue, 23 May 2023 20:44:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Ws6TGDP80HaLK1fwJLF2wY2CNHCy8BmrhncBSj7F037g7Ze7MqxrXZWebdS+olOWmNj/w X-Received: by 2002:a17:90b:1bc7:b0:253:828a:28f8 with SMTP id oa7-20020a17090b1bc700b00253828a28f8mr15239478pjb.25.1684899893637; Tue, 23 May 2023 20:44:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684899893; cv=none; d=google.com; s=arc-20160816; b=ocy0VDP+par70brNfCMdwKvzAUEAopMa231DDs1A96g4NA9hzfqvNECkffxO/uHy9Q ktGgISCpg6+1t+K9Kaxtph/v+a4fyo15T1hJ00KiSHdNtCoyIiB6Go8zDM9+3w+LN7fD U1ue+gLCdYrPpopZCT07cBe39XXpGPqzauGJN2eLgV08+VLEcO3vekcQTRlk/fs201ta XOllPnqC+uME9b6rlr3G2I1T0UM8WcNp4agcSa9ipzr/EKOMeWl0zIX3BJM9aDB8/7PE uFo75bm5R97SBNg5+flTt1a0m/noXWvIm4rxAbywOnbh6kV+sUhTRyi8MS1+Wbog6uyR K9qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WgqFNmLUsjBpqCt/LIT5GKl+BluIQMtFefGaXd2M17I=; b=qR4qJc2qvhezxOBo0jjpuNCsvyg9Lmc5vrSpA33uXWry2va4z3/rxksGXszTGFqZrr KLxcRzHIBF+FGtIygv1/v7/Sy2fWssrlpIPMz7kAYivNiotePhHOdQnoDNKe9A/htkkG YkqY7iz79NwRZBtvsQ6V+FAp51SLvxBapFBNBFjtZenDihEuf5HnXtClGzwJTkaMN+UV nyuQTtolx26O/XS49uAR4OpPR9XTAeDgT6O+fXtkgwbFjK4gD1kvXVrKIjj971OyE2Xa 1C7fZYI+8DoYwtyBUCHLN93pDAwYoz/mJYYiHTSCl6fYigcoME2Kme0UXjPRL/h7E4t1 Vtyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=fos9Fr5j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y6-20020a17090a1f4600b00250807ec16dsi514092pjy.97.2023.05.23.20.44.41; Tue, 23 May 2023 20:44:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=fos9Fr5j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239336AbjEXDP0 (ORCPT + 99 others); Tue, 23 May 2023 23:15:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239191AbjEXDOZ (ORCPT ); Tue, 23 May 2023 23:14:25 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A18619D for ; Tue, 23 May 2023 20:13:39 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1ae87bdc452so3237325ad.2 for ; Tue, 23 May 2023 20:13:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684898019; x=1687490019; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WgqFNmLUsjBpqCt/LIT5GKl+BluIQMtFefGaXd2M17I=; b=fos9Fr5j7HfGCNewdVHPba52r/od/Xq+HkXaE/eBVHR4axkXK0nFdYi0oZZCCy7z6j Ot3MbKyYncgN49VuQuaicHywCvA4q8+r4AghQkyphciFzgep109ZY4LKjb9lhUwztXIN 3/uF6rSQdy/dt6dBkGKhxdSBO/qF8l3nH6p6sko1NwTHkLuOXTIZfQFKqDzJxlNwdaBv iN3+WueQq+mUfyQka+huDH6Wr5Qh3iNEDtj3hoYY+4m/M5HAVkQ0MjI2Rvdv3KlzAk79 nA32aCjmUw7mldHuv/7K7VxjoffhtwdiZMB6hXpYIWjVpcOEuWGegvx55XSCg40ZM/Jp 2d5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684898019; x=1687490019; h=content-transfer-encoding:mime-version: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=WgqFNmLUsjBpqCt/LIT5GKl+BluIQMtFefGaXd2M17I=; b=FwS2g8mjj0fc6f5jzoWxPkHNu6E/lPBukzAnCZ/ez87gDoVN146eIS443z1LKYo8JT lo3AwNh+6ViAJZQMuCATGOgjvX9HSX19B8o0jdqNWEMh1n/j5WK8cMfb5/WweXsBdNCE CYVgFe/rfeQiawx7OOuCn1N2x3SukEpZoek2EvfJ3/2vn0HbbRglD3rhPYr7X7ztP1/n 8mVbab1jTBJZWlS1gshHUjCnqchUysBraf3eg0hAGe7GJ3i1yz9qZP5euXGOaMIvir6g 5P+fNHA0WKdmp6VSdryUqm9/y+NygS41GIWI3JVZkcFKgqLKIYmcqsUB0V+RRHSAW8Zb nP1A== X-Gm-Message-State: AC+VfDyEJxaFOYr1AbL6P02H6eU97YQzx5AFi3G+CbsVXHXFi7Ua8u1G 06LEkHMQvJzf1HTsJRCBBU1BaA== X-Received: by 2002:a17:902:efd3:b0:1ad:164:74ee with SMTP id ja19-20020a170902efd300b001ad016474eemr15460302plb.15.1684898018881; Tue, 23 May 2023 20:13:38 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.249]) by smtp.gmail.com with ESMTPSA id i4-20020a17090332c400b001ab061e352bsm7480769plr.195.2023.05.23.20.13.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 May 2023 20:13:38 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH v4 09/10] maple_tree: Simplify and clean up mas_wr_node_store() Date: Wed, 24 May 2023 11:12:46 +0800 Message-Id: <20230524031247.65949-10-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230524031247.65949-1-zhangpeng.00@bytedance.com> References: <20230524031247.65949-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766745590526922492?= X-GMAIL-MSGID: =?utf-8?q?1766745590526922492?= Simplify and clean up mas_wr_node_store(), remove unnecessary code. Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 87 +++++++++++++++--------------------------------- 1 file changed, 26 insertions(+), 61 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 1a2b9bb9c014..bfffbb7cab26 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4074,52 +4074,27 @@ static inline int mas_wr_spanning_store(struct ma_wr_state *wr_mas) * * Return: True if stored, false otherwise */ -static inline bool mas_wr_node_store(struct ma_wr_state *wr_mas) +static inline bool mas_wr_node_store(struct ma_wr_state *wr_mas, + unsigned char new_end) { struct ma_state *mas = wr_mas->mas; void __rcu **dst_slots; unsigned long *dst_pivots; - unsigned char dst_offset; - unsigned char new_end = wr_mas->node_end; - unsigned char offset; - unsigned char node_slots = mt_slots[wr_mas->type]; + unsigned char dst_offset, offset_end = wr_mas->offset_end; struct maple_node reuse, *newnode; - unsigned char copy_size, max_piv = mt_pivots[wr_mas->type]; + unsigned char copy_size, node_pivots = mt_pivots[wr_mas->type]; bool in_rcu = mt_in_rcu(mas->tree); - offset = mas->offset; - if (mas->last == wr_mas->r_max) { - /* runs right to the end of the node */ - if (mas->last == mas->max) - new_end = offset; - /* don't copy this offset */ - wr_mas->offset_end++; - } else if (mas->last < wr_mas->r_max) { - /* new range ends in this range */ - if (unlikely(wr_mas->r_max == ULONG_MAX)) - mas_bulk_rebalance(mas, wr_mas->node_end, wr_mas->type); - - new_end++; - } else { - if (wr_mas->end_piv == mas->last) - wr_mas->offset_end++; - - new_end -= wr_mas->offset_end - offset - 1; - } - - /* new range starts within a range */ - if (wr_mas->r_min < mas->index) - new_end++; - - /* Not enough room */ - if (new_end >= node_slots) - return false; - - /* Not enough data. */ + /* Check if there is enough data. The room is enough. */ if (!mte_is_root(mas->node) && (new_end <= mt_min_slots[wr_mas->type]) && !(mas->mas_flags & MA_STATE_BULK)) return false; + if (mas->last == wr_mas->end_piv) + offset_end++; /* don't copy this offset */ + else if (unlikely(wr_mas->r_max == ULONG_MAX)) + mas_bulk_rebalance(mas, wr_mas->node_end, wr_mas->type); + /* set up node. */ if (in_rcu) { mas_node_count(mas, 1); @@ -4136,47 +4111,36 @@ static inline bool mas_wr_node_store(struct ma_wr_state *wr_mas) dst_pivots = ma_pivots(newnode, wr_mas->type); dst_slots = ma_slots(newnode, wr_mas->type); /* Copy from start to insert point */ - memcpy(dst_pivots, wr_mas->pivots, sizeof(unsigned long) * (offset + 1)); - memcpy(dst_slots, wr_mas->slots, sizeof(void *) * (offset + 1)); - dst_offset = offset; + memcpy(dst_pivots, wr_mas->pivots, sizeof(unsigned long) * mas->offset); + memcpy(dst_slots, wr_mas->slots, sizeof(void *) * mas->offset); /* Handle insert of new range starting after old range */ if (wr_mas->r_min < mas->index) { - mas->offset++; - rcu_assign_pointer(dst_slots[dst_offset], wr_mas->content); - dst_pivots[dst_offset++] = mas->index - 1; + rcu_assign_pointer(dst_slots[mas->offset], wr_mas->content); + dst_pivots[mas->offset++] = mas->index - 1; } /* Store the new entry and range end. */ - if (dst_offset < max_piv) - dst_pivots[dst_offset] = mas->last; - mas->offset = dst_offset; - rcu_assign_pointer(dst_slots[dst_offset], wr_mas->entry); + if (mas->offset < node_pivots) + dst_pivots[mas->offset] = mas->last; + rcu_assign_pointer(dst_slots[mas->offset], wr_mas->entry); /* * this range wrote to the end of the node or it overwrote the rest of * the data */ - if (wr_mas->offset_end > wr_mas->node_end || mas->last >= mas->max) { - new_end = dst_offset; + if (offset_end > wr_mas->node_end) goto done; - } - dst_offset++; + dst_offset = mas->offset + 1; /* Copy to the end of node if necessary. */ - copy_size = wr_mas->node_end - wr_mas->offset_end + 1; - memcpy(dst_slots + dst_offset, wr_mas->slots + wr_mas->offset_end, + copy_size = wr_mas->node_end - offset_end + 1; + memcpy(dst_slots + dst_offset, wr_mas->slots + offset_end, sizeof(void *) * copy_size); - if (dst_offset < max_piv) { - if (copy_size > max_piv - dst_offset) - copy_size = max_piv - dst_offset; - - memcpy(dst_pivots + dst_offset, - wr_mas->pivots + wr_mas->offset_end, - sizeof(unsigned long) * copy_size); - } + memcpy(dst_pivots + dst_offset, wr_mas->pivots + offset_end, + sizeof(unsigned long) * (copy_size - 1)); - if ((wr_mas->node_end == node_slots - 1) && (new_end < node_slots - 1)) + if (new_end < node_pivots) dst_pivots[new_end] = mas->max; done: @@ -4378,7 +4342,8 @@ static inline void mas_wr_modify(struct ma_wr_state *wr_mas) if (new_end == wr_mas->node_end && mas_wr_slot_store(wr_mas)) return; - else if (mas_wr_node_store(wr_mas)) + + if (mas_wr_node_store(wr_mas, new_end)) return; if (mas_is_err(mas)) From patchwork Wed May 24 03:12:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 98268 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2574412vqo; Tue, 23 May 2023 20:47:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ajCFLNJeJnBPIjlY518/B7Zu4CvqTPqFGqhzzPHL+P5wQtsIOmAYFl7NMKkv3/pNJOdQv X-Received: by 2002:a05:6a20:258c:b0:10c:89cc:bc5f with SMTP id k12-20020a056a20258c00b0010c89ccbc5fmr4216425pzd.20.1684900033298; Tue, 23 May 2023 20:47:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684900033; cv=none; d=google.com; s=arc-20160816; b=ww6NMcnWkSdY47PpNuMwcKP6OCMF7dmZt6cAyvizDUu3vB68BYK1aQ4t7icJKXoEPh fkFtBXbouHUaArv/sz2XdaVPDCVZg8ypG3ukV+vT7wGArny7w8StTNDuydd+KJeJQCnR 7wflUBrxgHe5qDZfDeaMC2WGbwuoAVqSaRm6mlPpO54YqbUsdLAOtfo4rIKwTWXbsD16 i0OSzBav21J4aK6hofjknfn3JI7AXwgObXORAxoY3me4hG2W7wHoVBfDUuC4AawQNzSk wxgWSR4svY9FSuGAGQAnDb1j5KBT/fpnXb6JQxe94amgJV04jjAnJJXtfGepVchkcbYz RpZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RV+E10z6xFr5GObbzUS/AcEhnoCetH+fwSlbsSYX4vY=; b=UOkeEB4oqJxZ1fVlc6QJpisyMVWLyjptcVBECXr8QbZ2WQo43L9BI+4afYGZ/FPL8a 4rRcXoBz5HTpVyQsngpFsbHNekkJov7fSP2Wfr3PIyV4sAqulxGwh5EltYcJMaXxbFxH C523rV0j4awDEWZfKL8rOxL/V/Kg3smUUr2SOP4hAfeThF/q/6CR2zXTxStuSb9dYDsa tXIdiS1ye3Vbe7JBzg+gK6qN1YYYabc+O4zNjkkBYgzIv5exfZPYIMw60iPLbkKlUTfc Nh1WQVdlIAFiq7jYU2g5wgMQjIQhpG1SFpyW7WFuzVLv5fy+OWp8s60fBz3YfQ8E2e2m pbbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=UEqQJrMO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j67-20020a636e46000000b0051b554df1c2si3609450pgc.497.2023.05.23.20.47.01; Tue, 23 May 2023 20:47:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=UEqQJrMO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239262AbjEXDOi (ORCPT + 99 others); Tue, 23 May 2023 23:14:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239122AbjEXDN7 (ORCPT ); Tue, 23 May 2023 23:13:59 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 621921A6 for ; Tue, 23 May 2023 20:13:42 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1ae3ed1b08eso4757405ad.0 for ; Tue, 23 May 2023 20:13:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684898022; x=1687490022; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RV+E10z6xFr5GObbzUS/AcEhnoCetH+fwSlbsSYX4vY=; b=UEqQJrMOHnp7tNX7Xow0fq26n4UkOiUISE4M7Opa3LuKIvoS3dhJJ0pqVVo2SLlHs8 6Qqpy3Eu1Kk08CjhUGgaFUpgTvqwnToIT35Fuppg5a6SaiPtz0c9rGgD9iaXf7kGpKLf rS9jqrOV2UtKcs1SiOtf56rgGQlYwIsWsBR4Xu4CfUbv+ajxw8ISYMIaxeaBTW2NfEzq lJuSO+qkX1c3cciGzclkIICDlZENpzNmPSqJg/s1ju/BkYi7dKl6yvDfpV6sTU3bXc9x lKEvIzWQPS7ntNGuM+n1OvdBANoB8EPXON4tpuiZV7OO1lTc1VkCZZYlWibCcyZ+H9Vb 9dWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684898022; x=1687490022; h=content-transfer-encoding:mime-version: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=RV+E10z6xFr5GObbzUS/AcEhnoCetH+fwSlbsSYX4vY=; b=D0JyPYWID3h92F0X/2hJCx2NIAvnhyD/QnjtCWJxTgS7FbBFiKuZV4XpxdiyY7Wlbo 3h/STdmLCv3rSOBIPXx7VUTLz9/EouHp3CGAg3059pN2NMEzamMu3NNSMrZJyO+DJrFW lpgkk/nkJPik3Vn8mG586BedCc/1vU/uHsUu0TSNxzqGbpok588ZnbjFWcf4X6kod8tZ l+DU5QGP0k+SInLs5gDiIWJicAzKbtm/Aga+fdYhGcaXNxQ2jXJLbr7nebJqgmzmZqX+ OJwV+JdUyH7N6iOKk39OT9xH4GSzB5w1pnsH7AoTh7lIfRyGRmflffQxbD5OGfP7vm+f DCag== X-Gm-Message-State: AC+VfDwQ1wuVN1qWJPJK32CkzOy3MB+8DnGXOZhgYlxw9GZgAIv/XhKc EgWC7Kc34WVVyZt3WDpTvBnJjA== X-Received: by 2002:a17:902:c412:b0:1af:d00c:7f04 with SMTP id k18-20020a170902c41200b001afd00c7f04mr5042927plk.12.1684898021782; Tue, 23 May 2023 20:13:41 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.249]) by smtp.gmail.com with ESMTPSA id i4-20020a17090332c400b001ab061e352bsm7480769plr.195.2023.05.23.20.13.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 May 2023 20:13:41 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH v4 10/10] maple_tree: Relocate the declaration of mas_empty_area_rev(). Date: Wed, 24 May 2023 11:12:47 +0800 Message-Id: <20230524031247.65949-11-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230524031247.65949-1-zhangpeng.00@bytedance.com> References: <20230524031247.65949-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766745737373664738?= X-GMAIL-MSGID: =?utf-8?q?1766745737373664738?= Relocate the declaration of mas_empty_area_rev() so that mas_empty_area() and mas_empty_area_rev() are together. Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- include/linux/maple_tree.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h index 541675229568..295548cca8b3 100644 --- a/include/linux/maple_tree.h +++ b/include/linux/maple_tree.h @@ -474,6 +474,12 @@ void *mas_next_range(struct ma_state *mas, unsigned long max); int mas_empty_area(struct ma_state *mas, unsigned long min, unsigned long max, unsigned long size); +/* + * This finds an empty area from the highest address to the lowest. + * AKA "Topdown" version, + */ +int mas_empty_area_rev(struct ma_state *mas, unsigned long min, + unsigned long max, unsigned long size); static inline void mas_init(struct ma_state *mas, struct maple_tree *tree, unsigned long addr) @@ -497,12 +503,6 @@ static inline bool mas_is_paused(const struct ma_state *mas) return mas->node == MAS_PAUSE; } -/* - * This finds an empty area from the highest address to the lowest. - * AKA "Topdown" version, - */ -int mas_empty_area_rev(struct ma_state *mas, unsigned long min, - unsigned long max, unsigned long size); /** * mas_reset() - Reset a Maple Tree operation state. * @mas: Maple Tree operation state.