From patchwork Wed Apr 12 12:48:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9677471 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5A5C060325 for ; Wed, 12 Apr 2017 12:48:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CDB8285FE for ; Wed, 12 Apr 2017 12:48:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4149C2866C; Wed, 12 Apr 2017 12:48:38 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham 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 E74FC285FE for ; Wed, 12 Apr 2017 12:48:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5E4EC6E6F8; Wed, 12 Apr 2017 12:48:37 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 960D56E6E6 for ; Wed, 12 Apr 2017 12:48:31 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id o81so6211267wmb.0 for ; Wed, 12 Apr 2017 05:48:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=uPQ/JkFzZfcj+CbeiPMt0BSwRCSBYvkM4tT4t5PXh7w=; b=cfXDZ2zFifAD74dwyZL0mhM9UENT4oO+77JPknqRJnCaV18CFt/md8YeTPvqehMqgC /w7NH/M8swHX2ggrq+93dKZ5stX3BKY2rZZxMfBeGKBugpQCfsL/wS7ykqIFNK4DBZlw OLFhn5Etv3dJShGlSlvPydDe0Ag38moJNWDfPoMqXYc6STXKUWVjISP87LkiG7f/ylCJ faRGwhqsUAWDYIriv7Wjd1VMm7ZoCeSjwZ2thOPoc81D/lDAaH9bsoyc23S/9yjZgeYa vzqUumlvlnLIo/i+0CW21eLEmmhBR7EPNlIQe+2lDA4p5ByFtVJqL5XpixRk4p5EwiJT 8XtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=uPQ/JkFzZfcj+CbeiPMt0BSwRCSBYvkM4tT4t5PXh7w=; b=lJpKnduCTGKh8kERDZgIGBujGxnhumsU5mOZ/sG57DaNF/GwtKSvr2jzk+ikA2h+r1 p0TxDUq2b75Xo3Vgv4IQLSnyJ/LICGIqDUcbmVttca0rSfNsWmX3M4y0VxxbTsFad9of gXtiMnRumes8uNVacZPOiNvp+WD7l6EY1iaKVkGrIq+eKt0e8XgNyX4c0ivQ5G9v+P98 4eTxKxSKStoBe5P5wQsHs/nH37545+IhmVa9szOidh1l5tQeZwPNQhytzJ4gLlOW6QRI /u3cZcagCjvNhTvgqmhVUP+smIYQb1PslUwflys8Mf10a3hTkvxWSs0Vq+s7OoUWM2Vf R8dg== X-Gm-Message-State: AN3rC/4/343bBuNFoyelQ4QgWFSqZWxJekBLkOWn8c0JmQwaQLfZf258q5C+KWKESwo8OQ== X-Received: by 10.28.130.198 with SMTP id e189mr2686956wmd.96.1492001310270; Wed, 12 Apr 2017 05:48:30 -0700 (PDT) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id a10sm25621345wra.17.2017.04.12.05.48.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Apr 2017 05:48:29 -0700 (PDT) From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Wed, 12 Apr 2017 13:48:19 +0100 Message-Id: <20170412124825.21741-3-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170412124825.21741-1-chris@chris-wilson.co.uk> References: <20170412124825.21741-1-chris@chris-wilson.co.uk> Subject: [Intel-gfx] [PATCH v2 3/9] drm/i915: Make ptr_unpack_bits() more function-like X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP ptr_unpack_bits() is a function-like macro, as such it is meant to be replaceable by a function. In this case, we should be passing in the out-param as a pointer. Bizarrely this does affect code generation: function old new delta i915_gem_object_pin_map 409 389 -20 An improvement(?) in this case, but one can't help wonder what strict-aliasing optimisations we are preventing. The generated code looks identical in using ptr_unpack_bits (no extra motions to stack, the pointer and bits appear to be kept in registers), the difference appears to be code ordering and with a reorder it is able to use smaller forward jumps. Signed-off-by: Chris Wilson Reviewed-by: Joonas Lahtinen --- drivers/gpu/drm/i915/i915_gem.c | 2 +- drivers/gpu/drm/i915/i915_utils.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 68c0a1c3bf77..d993a3cc8f97 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -2612,7 +2612,7 @@ void *i915_gem_object_pin_map(struct drm_i915_gem_object *obj, } GEM_BUG_ON(!obj->mm.pages); - ptr = ptr_unpack_bits(obj->mm.mapping, has_type); + ptr = ptr_unpack_bits(obj->mm.mapping, &has_type); if (ptr && has_type != type) { if (pinned) { ret = -EBUSY; diff --git a/drivers/gpu/drm/i915/i915_utils.h b/drivers/gpu/drm/i915/i915_utils.h index c5455d36b617..aca11aad5da7 100644 --- a/drivers/gpu/drm/i915/i915_utils.h +++ b/drivers/gpu/drm/i915/i915_utils.h @@ -77,7 +77,7 @@ #define ptr_unpack_bits(ptr, bits) ({ \ unsigned long __v = (unsigned long)(ptr); \ - (bits) = __v & ~PAGE_MASK; \ + *(bits) = __v & ~PAGE_MASK; \ (typeof(ptr))(__v & PAGE_MASK); \ })