Message ID | 20230418171524.274386-1-npache@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3025412vqo; Tue, 18 Apr 2023 10:45:52 -0700 (PDT) X-Google-Smtp-Source: AKy350YiMZWRZ7IrUAw7pWdvcqMpoIwrvLZ2CrdjG0PTdRAWSDMjxcTHeaUkB8qw6Jhns841VxBf X-Received: by 2002:a17:90b:4a45:b0:247:2969:4f95 with SMTP id lb5-20020a17090b4a4500b0024729694f95mr407369pjb.26.1681839951724; Tue, 18 Apr 2023 10:45:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681839951; cv=none; d=google.com; s=arc-20160816; b=SsQbOtjLhHgmy8eopEF1efjlZ92IwuA6kxFEuOw1VAstBWynt4mJ040P+Gw/2vMLiv R1WJZY8S6tve29znQVsHJv5Qizp+ILW1aZHg2wVFfKR0q8jiI0ThtUcZytoF23CEGIh1 rAPyGfL0i5uJsyoXVFz19bBrTA3k3l2645o1/bJRI7tb6dRtb24xmDa5JrXh0XAR9Y76 h5uCnRILbOPktD0NFEnoa9LLnPowrI014x6zryjs5GMZY0QCvTMMwlBtq98FJk0zAJUQ v9pXOj1P+k+uB4vsDD7b1SKgdOkj7k0Bzkm0MEAFkD1SUJ/TjDGIfRioL1ZMwpTbZKFd eEDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=914MbDCapASQxkK9BuyG9zv/qlx7fwHmIuJzggClNB8=; b=G5EGAUa8xk191alwOpBBxb4GcyRpQMEAFTBYT0zDRNXGOVQC9CqLw5P6slGC+P45eJ 5RnLUrRfnPYXTOiX5m4l4L7OY7LfsgeaUwZhxroB7gLPsoIWTra3+6emx9aVi6+Q8d5q pg/dhODo293iJmEjkKlLCkVkEdXxz92KPv77I3H8OCt3ijtwNZC6hi5PQ1JVH1NuUjA7 iZIt8FxPLaMAQDHNgrfoXq2DbuhzsJwnK/2PcIoISEW3kAFAiD9aaRVOYkbIYYyf+4vR 56CT5d+jSk6De7i4Y5oaoNkmc16NBBelNSXm/oRw6B+ZhANRqPYEgkayfGp7Dw8/tI31 uxHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YfUDg95r; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x2-20020a17090abc8200b00246869a3320si13972136pjr.178.2023.04.18.10.45.38; Tue, 18 Apr 2023 10:45:51 -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=YfUDg95r; 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 S231875AbjDRRQs (ORCPT <rfc822;leviz.kernel.dev@gmail.com> + 99 others); Tue, 18 Apr 2023 13:16:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230070AbjDRRQr (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 18 Apr 2023 13:16:47 -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 4BACD13C06 for <linux-kernel@vger.kernel.org>; Tue, 18 Apr 2023 10:15:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681838137; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=914MbDCapASQxkK9BuyG9zv/qlx7fwHmIuJzggClNB8=; b=YfUDg95rEqPqVXorOmWHQ9LrAR976TPtw2mpe6ij83xxr4PJPiWzjf7EbH9Ccp/Cz5NRdD vGsM4tjoCPyso+VDzfXeSMSUlkCH8iB5vOfROfqm8MotK4Hyj3X4wLMbF90Gm5xY0/4n53 jYYp3r4NIadfyDSYN7sRl5ekXZ5uO4Y= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-497-YKyY_ucKP2uNreI52tG6sw-1; Tue, 18 Apr 2023 13:15:31 -0400 X-MC-Unique: YKyY_ucKP2uNreI52tG6sw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7696E101A551; Tue, 18 Apr 2023 17:15:28 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.22.10.203]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C23540C20FA; Tue, 18 Apr 2023 17:15:27 +0000 (UTC) From: Nico Pache <npache@redhat.com> To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: matthew.auld@intel.com, arunpravin.paneerselvam@amd.com, arthurgrillo@riseup.net, davidgow@google.com, javierm@redhat.com, christian.koenig@amd.com, mairacanal@riseup.net, daniel@ffwll.ch, airlied@gmail.com, ddutile@redhat.com, kunit-dev@googlegroups.com Subject: [PATCH] kunit: drm: make DRM buddy test compatible with other pages sizes Date: Tue, 18 Apr 2023 11:15:24 -0600 Message-Id: <20230418171524.274386-1-npache@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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_NONE, RCVD_IN_MSPIKE_H2,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763537008879919601?= X-GMAIL-MSGID: =?utf-8?q?1763537008879919601?= |
Series |
kunit: drm: make DRM buddy test compatible with other pages sizes
|
|
Commit Message
Nico Pache
April 18, 2023, 5:15 p.m. UTC
The DRM buddy test uses a fixed 12 bit shift to covert from pages to
bytes. This number is then used to confirm that (chunk_size < PAGE_SIZE)
which can lead to a failing drm_buddy_init on systems with PAGE_SIZE > 4k.
Fixes: 92937f170d3f ("drm/selftests: add drm buddy alloc range testcase")
Signed-off-by: Nico Pache <npache@redhat.com>
---
drivers/gpu/drm/tests/drm_buddy_test.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On Wed, 19 Apr 2023 at 01:15, Nico Pache <npache@redhat.com> wrote: > > The DRM buddy test uses a fixed 12 bit shift to covert from pages to > bytes. This number is then used to confirm that (chunk_size < PAGE_SIZE) > which can lead to a failing drm_buddy_init on systems with PAGE_SIZE > 4k. > > Fixes: 92937f170d3f ("drm/selftests: add drm buddy alloc range testcase") > Signed-off-by: Nico Pache <npache@redhat.com> > --- Nice catch! This makes sense to me (and doesn't regress anything on my various 4k-page machines, at least). Reviewed-by: David Gow <davidgow@google.com> Cheers, -- David > drivers/gpu/drm/tests/drm_buddy_test.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/tests/drm_buddy_test.c b/drivers/gpu/drm/tests/drm_buddy_test.c > index 09ee6f6af896..a62b2690d3c2 100644 > --- a/drivers/gpu/drm/tests/drm_buddy_test.c > +++ b/drivers/gpu/drm/tests/drm_buddy_test.c > @@ -318,8 +318,8 @@ static void mm_config(u64 *size, u64 *chunk_size) > s &= -ms; > > /* Convert from pages to bytes */ > - *chunk_size = (u64)ms << 12; > - *size = (u64)s << 12; > + *chunk_size = (u64)ms << PAGE_SHIFT; > + *size = (u64)s << PAGE_SHIFT; > } > > static void drm_test_buddy_alloc_pathological(struct kunit *test) > -- > 2.39.2 >
Am 18.04.23 um 19:15 schrieb Nico Pache: > The DRM buddy test uses a fixed 12 bit shift to covert from pages to > bytes. This number is then used to confirm that (chunk_size < PAGE_SIZE) > which can lead to a failing drm_buddy_init on systems with PAGE_SIZE > 4k. Since the buddy allocator is used for resources which are independent of the CPU PAGE size the later check is actually the broken one. E.g. neither in the buddy allocator nor in it's test cases we should have any of PAGE_SHIFT or PAGE_SIZE. Otherwise the allocator wouldn't work correctly on systems with a PAGE_SIZE different than 4k. Regards, Christian. > > Fixes: 92937f170d3f ("drm/selftests: add drm buddy alloc range testcase") > Signed-off-by: Nico Pache <npache@redhat.com> > --- > drivers/gpu/drm/tests/drm_buddy_test.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/tests/drm_buddy_test.c b/drivers/gpu/drm/tests/drm_buddy_test.c > index 09ee6f6af896..a62b2690d3c2 100644 > --- a/drivers/gpu/drm/tests/drm_buddy_test.c > +++ b/drivers/gpu/drm/tests/drm_buddy_test.c > @@ -318,8 +318,8 @@ static void mm_config(u64 *size, u64 *chunk_size) > s &= -ms; > > /* Convert from pages to bytes */ > - *chunk_size = (u64)ms << 12; > - *size = (u64)s << 12; > + *chunk_size = (u64)ms << PAGE_SHIFT; > + *size = (u64)s << PAGE_SHIFT; > } > > static void drm_test_buddy_alloc_pathological(struct kunit *test)
Hi Christian, Thanks for the information! I am not very familiar with the inner workings of DRM, so I'm not really in a position to make any large or systematic changes to the test regarding the points you made. I am mainly trying to allow the tests to be run on more diverse hardware. From the looks of it this test has been adapted from an older test, so perhaps this rule was set in place in the past. Either way, I dont think my changes are going to break anything, so for the time being I think this small change is the best approach. Please let me know if you think otherwise. David, do you still have this on your radar? We've been carrying this as a RHEL-only since I originally posted it and have not noticed any issues due to it. Cheers, -- Nico On Wed, Apr 19, 2023 at 4:30 AM Christian König <christian.koenig@amd.com> wrote: > > Am 18.04.23 um 19:15 schrieb Nico Pache: > > The DRM buddy test uses a fixed 12 bit shift to covert from pages to > > bytes. This number is then used to confirm that (chunk_size < PAGE_SIZE) > > which can lead to a failing drm_buddy_init on systems with PAGE_SIZE > 4k. > > Since the buddy allocator is used for resources which are independent of > the CPU PAGE size the later check is actually the broken one. > > E.g. neither in the buddy allocator nor in it's test cases we should > have any of PAGE_SHIFT or PAGE_SIZE. > > Otherwise the allocator wouldn't work correctly on systems with a > PAGE_SIZE different than 4k. > > Regards, > Christian. > > > > > Fixes: 92937f170d3f ("drm/selftests: add drm buddy alloc range testcase") > > Signed-off-by: Nico Pache <npache@redhat.com> > > --- > > drivers/gpu/drm/tests/drm_buddy_test.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/gpu/drm/tests/drm_buddy_test.c b/drivers/gpu/drm/tests/drm_buddy_test.c > > index 09ee6f6af896..a62b2690d3c2 100644 > > --- a/drivers/gpu/drm/tests/drm_buddy_test.c > > +++ b/drivers/gpu/drm/tests/drm_buddy_test.c > > @@ -318,8 +318,8 @@ static void mm_config(u64 *size, u64 *chunk_size) > > s &= -ms; > > > > /* Convert from pages to bytes */ > > - *chunk_size = (u64)ms << 12; > > - *size = (u64)s << 12; > > + *chunk_size = (u64)ms << PAGE_SHIFT; > > + *size = (u64)s << PAGE_SHIFT; > > } > > > > static void drm_test_buddy_alloc_pathological(struct kunit *test) >
diff --git a/drivers/gpu/drm/tests/drm_buddy_test.c b/drivers/gpu/drm/tests/drm_buddy_test.c index 09ee6f6af896..a62b2690d3c2 100644 --- a/drivers/gpu/drm/tests/drm_buddy_test.c +++ b/drivers/gpu/drm/tests/drm_buddy_test.c @@ -318,8 +318,8 @@ static void mm_config(u64 *size, u64 *chunk_size) s &= -ms; /* Convert from pages to bytes */ - *chunk_size = (u64)ms << 12; - *size = (u64)s << 12; + *chunk_size = (u64)ms << PAGE_SHIFT; + *size = (u64)s << PAGE_SHIFT; } static void drm_test_buddy_alloc_pathological(struct kunit *test)