From patchwork Tue Jun 6 22:31:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13269809 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 94A9BC77B7A for ; Tue, 6 Jun 2023 22:31:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C0158E0002; Tue, 6 Jun 2023 18:31:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 270AD6B0074; Tue, 6 Jun 2023 18:31:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0EA628E0002; Tue, 6 Jun 2023 18:31:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id F10926B0072 for ; Tue, 6 Jun 2023 18:31:50 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C58D51A0868 for ; Tue, 6 Jun 2023 22:31:50 +0000 (UTC) X-FDA: 80873771580.11.17D8E6D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf22.hostedemail.com (Postfix) with ESMTP id A67C5C0004 for ; Tue, 6 Jun 2023 22:31:48 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="b6iAn+v/"; spf=pass (imf22.hostedemail.com: domain of dakr@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dakr@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686090708; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TgaMBAQqmFIKSof0UPPW7FVba5nvGkZRXtKURLuSZuM=; b=enoYF8Pn4HkaDHW/exyIgatZMEUqqYk2OU8CsFqgjoyqkyUnisZmzWtxtgw5XHXo2sfk06 iG8Y5wz9QMz4GH56GqRt/C10ur8gd4wgaluDDCbpXY/JUM9IHiQeTt8h7X/ITWQUqMDdmv XNKSOfkRRCaOhAYTUOdUimVhmtDCn9c= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686090708; a=rsa-sha256; cv=none; b=VoeKXlVlWvW99uaYYA0wjUowDuPsAlUisfgxbkOWpmJMq/YGktCCqwMcMEEtdkNeZXoxuk hkeJS+Y1ltSIKKincD0Yk/AO2h5tDZyTTrPP8UiHpF6aXLYVjJNqW/vQul0jOSu6v0e9kA gav3vd549825eZhdjIkbWKB8gZMCZXc= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="b6iAn+v/"; spf=pass (imf22.hostedemail.com: domain of dakr@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dakr@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686090708; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TgaMBAQqmFIKSof0UPPW7FVba5nvGkZRXtKURLuSZuM=; b=b6iAn+v/Rkt5njUfSGKPs4fmUhP2tPwvOYONKcSEKBkrB8jNNt1zeKK4UZ46mepeELetOi vhd4vz/oBNxgyQRWYyMHPCqZ6CYadCvbEXHuPSlR3V/KOZGQrK69jaDCJDaYhvBhCIT76w mf2xMiTiZnLhfBQrWlGzny3bRA/nYSQ= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-316-oT2FOLnYPVuVx4x6BQ1LzQ-1; Tue, 06 Jun 2023 18:31:46 -0400 X-MC-Unique: oT2FOLnYPVuVx4x6BQ1LzQ-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-97594143f1fso454677466b.3 for ; Tue, 06 Jun 2023 15:31:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686090705; x=1688682705; 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=TgaMBAQqmFIKSof0UPPW7FVba5nvGkZRXtKURLuSZuM=; b=GVzoUp44pJid89wBCejewEm/PkZImUUWN8dcE/5WhY1pjePA5xy8PIictno920g4P1 syFcmHmzQSdNXXI2smK76/T/5V/Df6QqyJ8VW322sDKX4YUeG9VmoIWz4Hu+oDBgt1KE izK/xRuvk2NFxAnK9pC2lLjDmJkm/hBj3zHOCROPIm0uUK6/PgwZfPkYwg8T95rYm8P3 RlPzwN58MmvLcKTYH7QIg/BFq4f4dwgkkXjhkgNxgNo1icVQ7gwFI6SuKz/4/FwEPlnh /nmgCFUU8RBr4fTcUyrql+etddMjSdOzo7QCtiJVnnnWP307nhk5rFK0IDjDsE21JXtk 6z3A== X-Gm-Message-State: AC+VfDyMNu4QTRAu5r8lpeZxaxbhpmWNjAkGzSh3CmWGUV6MaRtbqGQl t6UWPbndA5tGLO+tIbUnImP3wmuwoBPp6DhxWISBc/AE0eRFBKCvjbHm0l3wQIroc1HryqxLPHg kffpMACVwqx0= X-Received: by 2002:a17:907:7f1f:b0:974:55ea:1ad8 with SMTP id qf31-20020a1709077f1f00b0097455ea1ad8mr4182402ejc.63.1686090705433; Tue, 06 Jun 2023 15:31:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7k+gI0czoVmC921zhzIqzKXOHylci9OpwOhdlMHjnqE4m4dX7VavWWqZ5q7J8PkPFhDWIb4g== X-Received: by 2002:a17:907:7f1f:b0:974:55ea:1ad8 with SMTP id qf31-20020a1709077f1f00b0097455ea1ad8mr4182384ejc.63.1686090705309; Tue, 06 Jun 2023 15:31:45 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:de9c:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id rh19-20020a17090720f300b0094edbe5c7ddsm6162646ejb.38.2023.06.06.15.31.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 15:31:44 -0700 (PDT) From: Danilo Krummrich To: airlied@gmail.com, daniel@ffwll.ch, tzimmermann@suse.de, mripard@kernel.org, corbet@lwn.net, christian.koenig@amd.com, bskeggs@redhat.com, Liam.Howlett@oracle.com, matthew.brost@intel.com, boris.brezillon@collabora.com, alexdeucher@gmail.com, ogabbay@kernel.org, bagasdotme@gmail.com, willy@infradead.org, jason@jlekstrand.net Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Danilo Krummrich Subject: [PATCH drm-next v4 02/14] maple_tree: split up MA_STATE() macro Date: Wed, 7 Jun 2023 00:31:18 +0200 Message-Id: <20230606223130.6132-3-dakr@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230606223130.6132-1-dakr@redhat.com> References: <20230606223130.6132-1-dakr@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Stat-Signature: 8ibgpwo6u59snytqedezd37uno1acbjp X-Rspamd-Server: rspam10 X-Rspamd-Queue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zHOO4Ll+/c5NsYnpeTWH4ynsbgKSMlhUUMRIK6RehIKNiOXJUh+azDa3xZ6K82Ejs6y2hiNB2wF8puQwErJ/OAH7RLlSwhnRQlr9quzmzPLoiTJXqwUqmtxrdKN/Bu37rxM0dJkWY1MgPiS2ALbVANfALZH6SFQismkiFwS6CDPu6CGPvnuFg+Vd85tyI8mP1AUQl2n1Dyn5tSIx5YldWO/CerNuU1xv/UIGI7BZ9kp9ly3K0obnUzglR4xVEB0FOGZbBGhT78DCDV3wqIqpCqrV9oV88X2R0c+jzJOLroDdKi7iBBLyMxgaYyVPSZ8VRVI3FgXXK2HU6DZhWQJP/KqBK9MZ4hn3xOBroSV5dg8VSCDvnjG5JMDmK8oo84MQGPC5GWfz6NxdaMQ008Z5 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: Split up the MA_STATE() macro such that components using the maple tree can easily inherit from struct ma_state and build custom tree walk macros to hide their internals from users. Example: struct sample_iterator { struct ma_state mas; struct sample_mgr *mgr; }; \#define SAMPLE_ITERATOR(name, __mgr, start) \ struct sample_iterator name = { \ .mas = MA_STATE_INIT(&(__mgr)->mt, start, 0), \ .mgr = __mgr, \ } \#define sample_iter_for_each_range(it__, entry__, end__) \ mas_for_each(&(it__).mas, entry__, end__) Reviewed-by: Liam R. Howlett --- struct sample *sample; SAMPLE_ITERATOR(si, min); sample_iter_for_each_range(&si, sample, max) { frob(mgr, sample); } Signed-off-by: Danilo Krummrich --- include/linux/maple_tree.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h index 1fadb5f5978b..87d55334f1c2 100644 --- a/include/linux/maple_tree.h +++ b/include/linux/maple_tree.h @@ -423,8 +423,8 @@ struct ma_wr_state { #define MA_ERROR(err) \ ((struct maple_enode *)(((unsigned long)err << 2) | 2UL)) -#define MA_STATE(name, mt, first, end) \ - struct ma_state name = { \ +#define MA_STATE_INIT(mt, first, end) \ + { \ .tree = mt, \ .index = first, \ .last = end, \ @@ -435,6 +435,9 @@ struct ma_wr_state { .mas_flags = 0, \ } +#define MA_STATE(name, mt, first, end) \ + struct ma_state name = MA_STATE_INIT(mt, first, end) + #define MA_WR_STATE(name, ma_state, wr_entry) \ struct ma_wr_state name = { \ .mas = ma_state, \