From patchwork Tue Jun 20 00:42:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13285073 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 C6E3AEB64D9 for ; Tue, 20 Jun 2023 00:42:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3D28F8D0005; Mon, 19 Jun 2023 20:42:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 382C78D0001; Mon, 19 Jun 2023 20:42:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 24A9C8D0005; Mon, 19 Jun 2023 20:42:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 15FE78D0001 for ; Mon, 19 Jun 2023 20:42:42 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id E9F79AF816 for ; Tue, 20 Jun 2023 00:42:41 +0000 (UTC) X-FDA: 80921275722.12.24BE518 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf07.hostedemail.com (Postfix) with ESMTP id DE0E440003 for ; Tue, 20 Jun 2023 00:42:39 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DgqeOzxB; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of dakr@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dakr@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687221759; 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=C9apoWPgHQ+HttjrVOmvMmvBAGzRpC/qILH8eE4EO5c=; b=My9kQgjFQZc6MXQFSVwolxWuNMAegpVwxbe4qGwRNUwKvHzrQGe6tYhynVuVUmumXOnbyT jqrN7w0j5pm2/lXBVC9wpQzFgeP6YXnwGqrtgztXsIk1W9EB4Se7gEjNgrl5yLMD3rPDwB WF4/PxoSNmjnXNStVXaClCYVXwdbo5U= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DgqeOzxB; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of dakr@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dakr@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687221759; a=rsa-sha256; cv=none; b=xwKnT1cLAqxpfgmiDMoQBH7bFBfqc+u7xUT8+7PR/Wp/JxEidBkBcw8y0WuSet77uRN0AV vaL4YeviyCOI7D2ecEgf3jqNETB0aOfxozRVjkUE6mUXUWkU+5UkzopCafzm32Ns2uiA5g RI5b8+VoePo+ShwsGvl3vuEeezzHHL0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687221759; 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=C9apoWPgHQ+HttjrVOmvMmvBAGzRpC/qILH8eE4EO5c=; b=DgqeOzxBh5hfGYhUrKmiQfs/vPhfg9pIkj+ROChGmK6lMQ87aQuz/pBPpCSycygA2/ISlw Fcf1V6xOF32CcFkvrDGK341n6qZok0GXhhDpd4PEaqlEQTESO0KT6qwzoPZlT77WvZ+tvQ LvKK5vnJVDMP8l9IXXZnHOZ8d3FQTLk= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-281-vvAord40N62I2ttb8RL_4A-1; Mon, 19 Jun 2023 20:42:35 -0400 X-MC-Unique: vvAord40N62I2ttb8RL_4A-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-982180ac15cso320276566b.2 for ; Mon, 19 Jun 2023 17:42:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687221754; x=1689813754; 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=C9apoWPgHQ+HttjrVOmvMmvBAGzRpC/qILH8eE4EO5c=; b=dJfZPM+NAxgYUgmoYWxvWQ1HYckr4eiR7gsAbYNeZOa6p5EF3Gh6R2yEaOuWA5ah8i o9Exl0Nig4rMOk98fZu0KQlibycXcAsEjuvhagfpVwGxEGYFt3WKKrGXJhBveEr1H7Ta P3QEi14VfNSIkD4IQoQs9Xl+yT/Mj2RHgYiTZvFkBPMXt6wztPOszRjkCwypd1LU2zIm 0y1sTj0MRYnmF+xe+7mA4vSW5OBwsWpN6wGrzoA3350ZHIg3snGRcbOt+q8By3ZcNAm6 sDTjedtDUsCx3/lN/XfmYNz1EkAwbs/5OfnJZjz86rfshEVpkz4CsegAk8/uawBGsgzS FFAg== X-Gm-Message-State: AC+VfDw0BuhlXlBtrIY28KlNo3oOaYfpyBmTMci9jeDghUgqKNZ2Qaog 1RTXAsezMuHAvtbPzKMB5wmoYhRg/H6wFPR2yzTU4ShxRkg9WJucCrTWZWEBBhXzlaY80WmxvGA flN7yqPel+yY= X-Received: by 2002:a17:907:3e0a:b0:8b1:7de3:cfaa with SMTP id hp10-20020a1709073e0a00b008b17de3cfaamr11230757ejc.3.1687221754040; Mon, 19 Jun 2023 17:42:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7CuI4jncrqThsJCOY9EL8v0SHvOVlwMCpxRyLtkLTLUI18H8CeggEpcXJgjnduPuXIFRYrhA== X-Received: by 2002:a17:907:3e0a:b0:8b1:7de3:cfaa with SMTP id hp10-20020a1709073e0a00b008b17de3cfaamr11230750ejc.3.1687221753916; Mon, 19 Jun 2023 17:42:33 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:de9c:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id c16-20020a17090603d000b00986e6a7d230sm377729eja.168.2023.06.19.17.42.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 17:42:33 -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 v5 02/14] maple_tree: split up MA_STATE() macro Date: Tue, 20 Jun 2023 02:42:05 +0200 Message-Id: <20230620004217.4700-3-dakr@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230620004217.4700-1-dakr@redhat.com> References: <20230620004217.4700-1-dakr@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspam-User: X-Stat-Signature: g6seoqha8hrp66tzh8swaa8ikoigqcgh X-Rspamd-Server: rspam07 X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2wxlVmkjUKVHGajN58S02uQLYiT2ArnCFYCwLDAdI8sJDqqTLipMBlhNcTO8xWUydCyYZSwjLnMqSXQrYtP84PwDn34IlLP0WMyI4V+AOWHX5tTfVRird9/KMNw88IYYWi9ipQG/QWQMpNkjQbBrYvC4oj7QoHzGgPL2Sp6uZx+qcbudveGkgvYvUvm0gMd8ix1myZb+gEfL75DQgXuarUUCz+DBgnuyppTqliIwDNYjFGaCYg113bZ7jGv/zhYoQd4Td6GKb+WuZabY3e411UTn6caeVp9NBEM1tYSd0IxF0zITHa2n+CFpCuz9Aq/9VZtyWau6ymwdfcsD2FPIUncSRC3BuObEUMpux5vRUmO6wbN9Y8WO3ZzPHdCNjC8VtmBTN5FxHCKlvsXqzFOz+qZ60SMEhv0aq9071ow/fN5dZFg== 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__) --- struct sample *sample; SAMPLE_ITERATOR(si, min); sample_iter_for_each_range(&si, sample, max) { frob(mgr, sample); } Reviewed-by: Liam R. Howlett 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, \