Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp8638379rwp; Wed, 19 Jul 2023 12:58:03 -0700 (PDT) X-Google-Smtp-Source: APBJJlFTfuI9NuH9OsDZJNZwlqQlYOrYj62492znrRUkBBM3xYaxynfGcLA/ykKLmD0YBDzJ4p17 X-Received: by 2002:aa7:c258:0:b0:51e:6a:b4ba with SMTP id y24-20020aa7c258000000b0051e006ab4bamr2241027edo.41.1689796683381; Wed, 19 Jul 2023 12:58:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689796683; cv=none; d=google.com; s=arc-20160816; b=Ojfu0itKe0QpNe98Zu5S0dZ1TDDXLeAvrPmAAIY2J0VkDfFgjHGMZV0sEGR9qhkctU PH/ZvCQUVd7uYoQI2EhOK3OMS7q9QOSWM93A1RS55tLQjaMyfJdCskts/Heu/IVQ/X0a ckmI6lRUypxvlS4RsJHs0OUAJnzjf8Yso04oyj5tD3xE5vSCmrh59SSH82KCmX9UsaGp V5ZAm9yl5+3PAy+KpRNPJRvqtgQo7413sEiHmDoxUk1h2eK6JZp4Dmi2e1Vjz/gvrXOd MVAWCqSCVSZN5axooECTjF6AZoyb8lKgoQcfXDyR1TOp1TmlR+JdLZQ9Z3N2k58lCrx+ Q1Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=l4X8keUZdQb2bH4NBTCOtLQ3Hj41EdN+SDgQPF1/pfY=; fh=jWGVz9nLTOoLJmk4bRhMtocyqq5v0XVLuYwQh1AGSqA=; b=gxS09GE0SrFzKrsJgsxTALQshfVYw8GBWv0FkhBFiLsqmoaiS8rPfuHS7z1s48cj/+ NXiK0AN1HxdDhppjlW38btTjEMOtxeBJ3W4mIAfnBNvKng+OucdOQtswgNMQHOrFgk1+ ntgVwMb2UEaagfBMy0FoxdQkCO9Hxghv98+j/+yvYpBHJCPEcD8EtQZ7Dl2WB3F3zZqY tbXMcohvs3Sprj3yF93rzAn1Fx3jBCkskjdo6b/zdytFQbhWE7HyTrFK9RZiLudCHJyQ nRPjnnkH30hccvI/U3DenByMeMmqdcaZNnV5NmvQXBYUZ5/ynPreuDiPBrNhC4MSCQde UnUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LevcImOQ; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t13-20020aa7d70d000000b0051a2c8c1e4esi3351337edq.418.2023.07.19.12.57.39; Wed, 19 Jul 2023 12:58:03 -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=@redhat.com header.s=mimecast20190719 header.b=LevcImOQ; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230297AbjGSTZx (ORCPT + 99 others); Wed, 19 Jul 2023 15:25:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229604AbjGSTZw (ORCPT ); Wed, 19 Jul 2023 15:25:52 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54DD8213D for ; Wed, 19 Jul 2023 12:24:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689794691; 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: in-reply-to:in-reply-to:references:references; bh=l4X8keUZdQb2bH4NBTCOtLQ3Hj41EdN+SDgQPF1/pfY=; b=LevcImOQEyH53widEzfHgn84r2PCWCT4YmHSpmAK5Wd6Xdw90DOS2hH2LcVrULaBdXQ9Z/ eCM68TZhrEszEI6o9r6kJ3YJRW48S44ziOokILimcVz7PA4cvtkkJFtUiZvvIWwpSJQQGk G8MP6x+Al1YgPJSZQQtVMqgEr4gncGU= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-15-EbyTc2IdNcKgJRUmwmbzgA-1; Wed, 19 Jul 2023 15:24:47 -0400 X-MC-Unique: EbyTc2IdNcKgJRUmwmbzgA-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3f5df65f9f4so39154935e9.2 for ; Wed, 19 Jul 2023 12:24:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689794686; x=1690399486; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=l4X8keUZdQb2bH4NBTCOtLQ3Hj41EdN+SDgQPF1/pfY=; b=Rh5USAYz4rIOo/wl6W01c0aGEVtF/N8BHBoegrarQIyI8JHSLdeHsezDPywIpRivAs LjkQS76vyjRXFRUC+wzaceH9eFBCPujYq0LxOaHeDcGD6vcXyyV/I0Wm6TWgalbAVo0I wcjJuBU1o7kukitD0Mveq7dciVmg5F0RqvTa8CIl5Sjzm3k7PT/Hli/t6MHLF2gJBoYF cBLQWljMuKig9/csX4Exlj/LiFFjg7wJZUt8nnAJ0SDLeYbhz+0Efmj8XuMaTz9IR28P Lx+r9HRancNupQtjfRF79NlL9NT/BiaY4jTEjamLIJ2SvebKXUHE65Irw51Uei2gsvOZ jKRA== X-Gm-Message-State: ABy/qLZ1Y9nPVYXsF/FHoN/unad7k5p11n0vaKcu8PQSxCsd25P5qJRN 39SszXQQQo45cZeK6wOx7EwFi0JXQYvCmbPlyQC17NDq8XGZV8ClRdyr3P42l5SkDUDgP0x6vzr 1tuu+XKTfBjFwaOa4UmOMQ0On X-Received: by 2002:adf:f803:0:b0:313:ebf3:f817 with SMTP id s3-20020adff803000000b00313ebf3f817mr694726wrp.22.1689794686778; Wed, 19 Jul 2023 12:24:46 -0700 (PDT) X-Received: by 2002:adf:f803:0:b0:313:ebf3:f817 with SMTP id s3-20020adff803000000b00313ebf3f817mr694713wrp.22.1689794686460; Wed, 19 Jul 2023 12:24:46 -0700 (PDT) Received: from localhost (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id h10-20020a5d4fca000000b00314172ba213sm5943825wrw.108.2023.07.19.12.24.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 12:24:46 -0700 (PDT) From: Javier Martinez Canillas To: suijingfeng , Maxime Ripard , David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: Re: [05/11] drm/tests: helpers: Create an helper to allocate a locking ctx In-Reply-To: References: <20230710-kms-kunit-actions-rework-v1-5-722c58d72c72@kernel.org> Date: Wed, 19 Jul 2023 21:24:45 +0200 Message-ID: <87lefbhfgi.fsf@minerva.mail-host-address-is-not-set> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, 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 suijingfeng writes: > Hi, > > On 2023/7/10 15:47, Maxime Ripard wrote: >> As we get more and more tests, the locking context initialisation [...] >> +/** >> + * drm_kunit_helper_context_alloc - Allocates an acquire context >> + * @test: The test context object >> + * >> + * Allocates and initializes a modeset acquire context. >> + * >> + * The context is tied to the kunit test context, so we must not call >> + * drm_modeset_acquire_fini() on it, it will be done so automatically. >> + * >> + * Returns: >> + * An ERR_PTR on error, a pointer to the newly allocated context otherwise >> + */ >> +struct drm_modeset_acquire_ctx * >> +drm_kunit_helper_acquire_ctx_alloc(struct kunit *test) >> +{ >> + struct drm_modeset_acquire_ctx *ctx; >> + int ret; >> + >> + ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); > > Because kunit_kzalloc() is also managed, > > Is there any possibility that kfree(ctx) get called before > action_drm_release_context(ctx) ? > > Currently, I can't find where the order is guaranteed. > It isn't documented indeed in Documentation/dev-tools/kunit/usage.rst but the kunit_add_action() kernel-doc says: "All functions registered with kunit_add_action() will execute in the opposite order to that they were registered in". And now that kunit_kzalloc() and friends are also implemented using the cleanup actions, it will be part of that execution chain. Probably the kunit docs can make this more clear. -- Best regards, Javier Martinez Canillas Core Platforms Red Hat