From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.1 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 512B6C48BE5 for ; Fri, 11 Jun 2021 10:05:03 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1A2086124C for ; Fri, 11 Jun 2021 10:05:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1A2086124C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 338206EE5E; Fri, 11 Jun 2021 10:05:02 +0000 (UTC) Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 57DCC6E02B; Fri, 11 Jun 2021 10:05:01 +0000 (UTC) Received: by mail-wm1-x32e.google.com with SMTP id d184so7797007wmd.0; Fri, 11 Jun 2021 03:05:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=5xVxhVrGpeYgPINr7CYadkVeo4fwTn98UNDLrVw0lLA=; b=Y6YVR596mrBeh0jqyZNxmBsD3ZRzCOpAeNsWY8Ywo8p6Q8d78laE5dMl8idiebpli3 omITRKl4PuOkBOuqLeMLLfW5iEWE9QEV4l+zYnYA19nwq2dz5svJ7BE5ulfzqP+5J+0x byaR0LAlN/ZXzbxmbQ11TXQ5Cfx3H7WWOcf5w1/xZrcAxCgT7Kj6scAt/oooof8/U1bR OCaW0+D0SZ58eQj6Q6oVGHqA1Oyg+c965ZmQz9NIETv1uKSkhdxx9ajK50X+4wmWp0EQ kfk6/1LBKzmh7Z6lwsVRzVfg+h2BsfaG/U7crYOYIEzPVmmB+sPGTLz7AcqTmDtjnysl FeyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=5xVxhVrGpeYgPINr7CYadkVeo4fwTn98UNDLrVw0lLA=; b=aFpU0UrKE8Ck7QtsScQOs/9Zro3agDCiAB7a5L2JIDKZQol7EXw5ODBzFtLL14wyGL ITVRp5b5iWi2BbXehbc67ujBp/u4OEF6d9Io5W6DxWmCppWtguj7MYobKF/0B6OqOCnl zwwCcUpo7rhQPdwS6EOQxtyZkRmIhj9YwKv1EA8X+KW4+YLUFLHuxOiF5wWiTSz8YGZl hNZksUc8CDkn3s1qtNTfCtiizZ1QwxGMPHf0uT+Za7LXf9tV9h+nFYNH8WfeARnv4wMV DTQa1fM/RIafa+7wxikirxHI3R3fTx/xGkzPMI6AdkeQJOrGHGpNuCC/sariXlKagCSu pRdw== X-Gm-Message-State: AOAM531UTJFOLZZ7rbSuT35szuxxF4p0DSLeNWhWOyTRsPC1dwzZnWuW rSlUsVSqaPB+34GbDQ9m9MAjzTh5/Oc= X-Google-Smtp-Source: ABdhPJzJc5/S5B1hzsNZ2W9NdfCfL7C75qTUMj95HYrgYWvQFdeAPHUJFvkU4HADRHHnU0CZ7LTd6Q== X-Received: by 2002:a05:600c:1c28:: with SMTP id j40mr19509365wms.102.1623405900066; Fri, 11 Jun 2021 03:05:00 -0700 (PDT) Received: from ?IPv6:2a02:908:1252:fb60:108e:ba37:cb49:9c3? ([2a02:908:1252:fb60:108e:ba37:cb49:9c3]) by smtp.gmail.com with ESMTPSA id 2sm6345120wrz.87.2021.06.11.03.04.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Jun 2021 03:04:59 -0700 (PDT) Subject: Re: [PATCH 3/7] dma-buf: add dma_fence_chain_alloc/free self tests To: Daniel Vetter References: <20210610091800.1833-1-christian.koenig@amd.com> <20210610091800.1833-4-christian.koenig@amd.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: Date: Fri, 11 Jun 2021 12:04:58 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Am 11.06.21 um 09:58 schrieb Daniel Vetter: > On Thu, Jun 10, 2021 at 11:17:56AM +0200, Christian König wrote: >> Exercise the newly added functions. >> >> Signed-off-by: Christian König > I have honestly no idea what this checks. Spawning a few threads to > validate kmalloc/kfree feels a bit silly. Now testing whether we correctly > rcu-delay the freeing here would make some sense, but even that feels a > bit silly. > > I guess if you want this explain with comments what it does and why? This was soley to figure out if the garbage collection is working properly and how much overhead it generates. No actual need to commit it. Christian. > -Daniel > > >> --- >> drivers/dma-buf/st-dma-fence-chain.c | 48 ++++++++++++++++++++++++++++ >> 1 file changed, 48 insertions(+) >> >> diff --git a/drivers/dma-buf/st-dma-fence-chain.c b/drivers/dma-buf/st-dma-fence-chain.c >> index 8ce1ea59d31b..855c129c6093 100644 >> --- a/drivers/dma-buf/st-dma-fence-chain.c >> +++ b/drivers/dma-buf/st-dma-fence-chain.c >> @@ -95,6 +95,53 @@ static int sanitycheck(void *arg) >> return err; >> } >> >> +static int __alloc_free(void *arg) >> +{ >> + atomic_t *counter = arg; >> + int i, j; >> + >> + for (i = 0; i < 1024; ++i) { >> + struct dma_fence_chain *chains[64]; >> + >> + for (j = 0; j < ARRAY_SIZE(chains); ++j) >> + chains[j] = dma_fence_chain_alloc(); >> + >> + for (j = 0; j < ARRAY_SIZE(chains); ++j) >> + dma_fence_chain_free(chains[j]); >> + >> + atomic_add(ARRAY_SIZE(chains), counter); >> + } >> + return 0; >> +} >> + >> +static int alloc_free(void *arg) >> +{ >> + struct task_struct *threads[8]; >> + atomic_t counter = ATOMIC_INIT(0); >> + int i, err = 0; >> + >> + for (i = 0; i < ARRAY_SIZE(threads); i++) { >> + threads[i] = kthread_run(__alloc_free, &counter, "dmabuf/%d", >> + i); >> + if (IS_ERR(threads[i])) { >> + err = PTR_ERR(threads[i]); >> + break; >> + } >> + } >> + >> + while (i--) { >> + int ret; >> + >> + ret = kthread_stop(threads[i]); >> + if (ret && !err) >> + err = ret; >> + } >> + >> + pr_info("Completed %u cycles\n", atomic_read(&counter)); >> + >> + return err; >> +} >> + >> struct fence_chains { >> unsigned int chain_length; >> struct dma_fence **fences; >> @@ -677,6 +724,7 @@ int dma_fence_chain(void) >> { >> static const struct subtest tests[] = { >> SUBTEST(sanitycheck), >> + SUBTEST(alloc_free), >> SUBTEST(find_seqno), >> SUBTEST(find_signaled), >> SUBTEST(find_out_of_order), >> -- >> 2.25.1 >>