From patchwork Thu Aug 8 13:22:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 11085879 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B7D2912 for ; Fri, 9 Aug 2019 09:17:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CB4628C1E for ; Fri, 9 Aug 2019 09:17:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0161E28C54; Fri, 9 Aug 2019 09:17:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0B60028C1E for ; Fri, 9 Aug 2019 09:17:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3BB6B6EDD0; Fri, 9 Aug 2019 09:16:26 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4B9266E833; Thu, 8 Aug 2019 13:22:46 +0000 (UTC) Received: by mail-wr1-x444.google.com with SMTP id p13so20334426wru.10; Thu, 08 Aug 2019 06:22:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=sVwVfjzRRycoraZYR1eOD8IrhXOmA6ZHD0oG9OO+JDo=; b=IoeF5wSmxtc9nfISUjjcNJ1k2TY8mTJc2PQQiHWS2G9Ax8A0TYJtEFFaUfkXOZLyHq aDNhxc8AFqjUbD/LVDwbQ8RzDBDCZfKqzthdp8U/kM0c+kqf+xFKA96ldlerhgIotOV4 qnm1x5ptdaLrPLHswRHnvZcYyAyo44sMe4Z659FUdaGiB3zKntKmSzESrk4aVNnsqqiN 2Z+5OjqWp57jAAZgLpezvcCT/Q760tolc88QooXZ2jIT5Gh5qqAB2CTQEoIz/wdFsdxB PgKpQMBCpRg0k1GK/t7/AKN/W82Mm0O2yAyFVgNtzpMNQN8C3C/meg7q4L2AYNJ1d4Au QmKA== X-Gm-Message-State: APjAAAUIQdWIaMUJEtHUm7n4/sOA34/RI8uRI+JNL1EId9MtUDRy6NFg tLS7XC1jxiGSp2BQK5cJfuNrqw2N X-Google-Smtp-Source: APXvYqxe5UDrur+I80kg75qILxnX6soEqoUOPUMrSNEMWBE9Kaoj1PbStABq6MzLB4ecBxkc3Lu9FA== X-Received: by 2002:adf:fc81:: with SMTP id g1mr12942295wrr.78.1565270564778; Thu, 08 Aug 2019 06:22:44 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:9969:2269:d9b7:abda]) by smtp.gmail.com with ESMTPSA id o5sm3905225wrv.20.2019.08.08.06.22.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Aug 2019 06:22:44 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org Date: Thu, 8 Aug 2019 15:22:43 +0200 Message-Id: <20190808132243.23632-1-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 09 Aug 2019 09:15:44 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=sVwVfjzRRycoraZYR1eOD8IrhXOmA6ZHD0oG9OO+JDo=; b=hTG6jWrcTiROwe1qAItb2CQPPa/rhRAvKcpoLOqhcGOFq9QT7QbiEce7eDll2O6+X8 iHwZygEru06vYdjoWdcMiu9QHSChc9JYMxb2Zoa35VRjjy7yTfpZBqnINlyw0ma45+mI sVEl9tcb2Pm7fzdLcu3ZB64xMSOkzd4LrImwIEtDFfmFttUQD6RAw58/9AAAF2BXSq7w JlG6FI1ttC2K/hK9aLY6hU1+XWPImks+OGr7i9Tm688xyxuqkAFjcP10Osd7SBSpNrVm 8BJRXtvK1TuNtJGTWOP4wArMrKTW9L+G32fXALl+HIM4vGtW1m23GNkhuW7DeeqB9Sl8 3ZYw== Subject: [Intel-gfx] [PATCH] dma-buf: make dma_fence structure a bit smaller v2 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP We clear the callback list on kref_put so that by the time we release the fence it is unused. No one should be adding to the cb_list that they don't themselves hold a reference for. This small change is actually making the structure 16% smaller. v2: add the comment to the code as well. Signed-off-by: Christian König Reviewed-by: Chris Wilson --- include/linux/dma-fence.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h index 05d29dbc7e62..bea1d05cf51e 100644 --- a/include/linux/dma-fence.h +++ b/include/linux/dma-fence.h @@ -65,8 +65,14 @@ struct dma_fence_cb; struct dma_fence { struct kref refcount; const struct dma_fence_ops *ops; - struct rcu_head rcu; - struct list_head cb_list; + /* We clear the callback list on kref_put so that by the time we + * release the fence it is unused. No one should be adding to the cb_list + * that they don't themselves hold a reference for. + */ + union { + struct rcu_head rcu; + struct list_head cb_list; + }; spinlock_t *lock; u64 context; u64 seqno;