From patchwork Sun Jun 16 19:19:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arjan van de Ven X-Patchwork-Id: 2730581 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 081329F39E for ; Mon, 17 Jun 2013 06:21:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DAE572015C for ; Mon, 17 Jun 2013 06:21:20 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 5020720161 for ; Mon, 17 Jun 2013 06:21:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 66540E5C8B for ; Sun, 16 Jun 2013 23:20:35 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by gabe.freedesktop.org (Postfix) with ESMTP id 82257E5F47 for ; Sun, 16 Jun 2013 12:19:51 -0700 (PDT) Received: by mail-ve0-f174.google.com with SMTP id oz10so1609138veb.33 for ; Sun, 16 Jun 2013 12:19:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=BC/OkbZL5RCEy2wT8tFHDFUsqboPPe/die4y6SxsbPg=; b=Hu2ywmqSyHfph0MUVbhhZnVdnkOWdBHJBDEPgg8tKfkJCKiIOx6+tapqL7b2UGId/F KIJ+d3F1TRxJmzhYzSxLXU6m9UYcgajQuW7eh3cN92dH+jFJpQq+6BW5chUnYEx2d3QK 0UkzRIw6Qo8kHqP3coRy84z3wI93GffA2W+26aYxZLojTpRS4zGOyL24E/nXR2WhnSyD 1UclzB5OKPHqBHDS304k4OwLHGoyHH2j9FvCGfkcGhrdb2jlhmjo5zdEChDJqBmDJEji jw3KrNlpxNyQCsmFM6Gx0J8GPqQwvQomhWGwU7xyoD1AdGx3B5CZIiF+m7FFII9eYhJK hHVQ== MIME-Version: 1.0 X-Received: by 10.220.91.75 with SMTP id l11mr2510446vcm.82.1371410390504; Sun, 16 Jun 2013 12:19:50 -0700 (PDT) Received: by 10.221.41.67 with HTTP; Sun, 16 Jun 2013 12:19:50 -0700 (PDT) Date: Sun, 16 Jun 2013 12:19:50 -0700 Message-ID: Subject: [Patch] libdrm_intel: Mark large read only local arrays as static const From: Arjan van de Ven To: dri-devel@lists.freedesktop.org X-Mailman-Approved-At: Sun, 16 Jun 2013 22:35:14 -0700 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From 27eef3eba293163a0c2348566d2470978c3f6c0e Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Sun, 16 Jun 2013 10:56:35 -0700 Subject: [PATCH 1/2] intel: Mark large read only local arrays as static const In the instruction decoder, various arrays that are local to functions, but are read only, were not declared static const... causing the compiler to construct said array on the stack each call. Rather than using code to do this... just declare these arrays static const. In addition, to avoid relocations, use char [] instead of char * (as per DSOHowto), this may appear to waste a little bit of space, but that is very limited in practice, and it means these arrays can just be mapped in the read-only section. on x86-64, some basic size results Before: libdrm_intel.so.1.0.0: 76 relocations, 69 relative (90%), 56 PLT entries, 11 for local syms (19%) [11] .text PROGBITS 0000000000002c80 00002c80 00013c48 0 AX 0 0 16 [13] .rodata PROGBITS 00000000000168e0 000168e0 00005c3b 0 A 0 0 32 [19] .data.rel.ro PROGBITS 000000000021f018 0001f018 00000008 0 WA 0 0 8 [23] .data PROGBITS 000000000021f440 0001f440 00000640 0 WA 0 0 32 [24] .bss NOBITS 000000000021fa80 0001fa80 00000020 0 WA 0 0 8 After: libdrm_intel.so.1.0.0: 32 relocations, 25 relative (78%), 56 PLT entries, 11 for local syms (19%) [11] .text PROGBITS 0000000000002860 00002860 00011db8 0 AX 0 0 16 [13] .rodata PROGBITS 0000000000014640 00014640 00005c63 0 A 0 0 32 [19] .data.rel.ro PROGBITS 000000000021d020 0001d020 00001a08 0 WA 0 0 32 [23] .data PROGBITS 000000000021ee48 0001ee48 00000008 0 WA 0 0 4 [24] .bss NOBITS 000000000021ee50 0001ee50 00000048 0 WA 0 0 8 Signed-off-by: Arjan van de Ven --- intel/intel_decode.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) { 0x7828, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_DS" }, @@ -3208,10 +3208,10 @@ decode_3d_965(struct drm_intel_decode *ctx) { 0x782d, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_DS" }, { 0x782e, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_GS" }, { 0x782f, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_PS" }, - { 0x7830, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_VS }, - { 0x7831, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_HS }, - { 0x7832, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_DS }, - { 0x7833, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_GS }, + { 0x7830, 0x00ff, 2, 2, "", 7, gen7_3DSTATE_URB_VS }, + { 0x7831, 0x00ff, 2, 2, "", 7, gen7_3DSTATE_URB_HS }, + { 0x7832, 0x00ff, 2, 2, "", 7, gen7_3DSTATE_URB_DS }, + { 0x7833, 0x00ff, 2, 2, "", 7, gen7_3DSTATE_URB_GS }, { 0x7900, 0xffff, 4, 4, "3DSTATE_DRAWING_RECTANGLE" }, { 0x7901, 0xffff, 5, 5, "3DSTATE_CONSTANT_COLOR" }, { 0x7905, 0xffff, 5, 7, "3DSTATE_DEPTH_BUFFER" }, @@ -3233,8 +3233,8 @@ decode_3d_965(struct drm_intel_decode *ctx) { 0x7917, 0x00ff, 2, 2+128*2, "3DSTATE_SO_DECL_LIST" }, { 0x7918, 0x00ff, 4, 4, "3DSTATE_SO_BUFFER" }, { 0x7a00, 0x00ff, 4, 6, "PIPE_CONTROL" }, - { 0x7b00, 0x00ff, 7, 7, NULL, 7, gen7_3DPRIMITIVE }, - { 0x7b00, 0x00ff, 6, 6, NULL, 0, gen4_3DPRIMITIVE }, + { 0x7b00, 0x00ff, 7, 7, "", 7, gen7_3DPRIMITIVE }, + { 0x7b00, 0x00ff, 6, 6, "", 0, gen4_3DPRIMITIVE }, }, *opcode_3d = NULL; opcode = (data[0] & 0xffff0000) >> 16; @@ -3751,11 +3751,11 @@ decode_3d_i830(struct drm_intel_decode *ctx) uint32_t opcode; uint32_t *data = ctx->data; - struct { + static const struct { uint32_t opcode; unsigned int min_len; unsigned int max_len; - const char *name; + const char name[28]; } opcodes_3d[] = { { 0x02, 1, 1, "3DSTATE_MODES_3" }, { 0x03, 1, 1, "3DSTATE_ENABLES_1" }, -- 1.7.11.7 diff --git a/intel/intel_decode.c b/intel/intel_decode.c index ff19f92..fdbbe0c 100644 --- a/intel/intel_decode.c +++ b/intel/intel_decode.c @@ -229,12 +229,12 @@ decode_mi(struct drm_intel_decode *ctx) const char *post_sync_op = ""; uint32_t *data = ctx->data; - struct { + static const struct { uint32_t opcode; int len_mask; unsigned int min_len; unsigned int max_len; - const char *name; + const char name[24]; int (*func)(struct drm_intel_decode *ctx); } opcodes_mi[] = { { 0x08, 0, 1, 1, "MI_ARB_ON_OFF" }, @@ -420,11 +420,11 @@ decode_2d(struct drm_intel_decode *ctx) unsigned int opcode, len; uint32_t *data = ctx->data; - struct { + static const struct { uint32_t opcode; unsigned int min_len; unsigned int max_len; - const char *name; + const char name[38]; } opcodes_2d[] = { { 0x40, 5, 5, "COLOR_BLT" }, { 0x43, 6, 6, "SRC_COPY_BLT" }, @@ -1271,12 +1271,12 @@ decode_3d_1d(struct drm_intel_decode *ctx) uint32_t *data = ctx->data; uint32_t devid = ctx->devid; - struct { + static const struct { uint32_t opcode; int i830_only; unsigned int min_len; unsigned int max_len; - const char *name; + const char name[34]; } opcodes_3d_1d[] = { { 0x86, 0, 4, 4, "3DSTATE_CHROMA_KEY" }, { 0x88, 0, 2, 2, "3DSTATE_CONSTANT_BLEND_COLOR" }, @@ -2543,11 +2543,11 @@ decode_3d(struct drm_intel_decode *ctx) unsigned int idx; uint32_t *data = ctx->data; - struct { + static const struct { uint32_t opcode; unsigned int min_len; unsigned int max_len; - const char *name; + const char name[34]; } opcodes_3d[] = { { 0x06, 1, 1, "3DSTATE_ANTI_ALIASING" }, { 0x08, 1, 1, "3DSTATE_BACKFACE_STENCIL_OPS" }, @@ -3138,12 +3138,12 @@ decode_3d_965(struct drm_intel_decode *ctx) uint32_t *data = ctx->data; uint32_t devid = ctx->devid; - struct { + static const struct { uint32_t opcode; uint32_t len_mask; int unsigned min_len; int unsigned max_len; - const char *name; + const char name[34]; int gen; int (*func)(struct drm_intel_decode *ctx); } opcodes_3d[] = { @@ -3169,8 +3169,8 @@ decode_3d_965(struct drm_intel_decode *ctx) { 0x780a, 0x00ff, 3, 3, "3DSTATE_INDEX_BUFFER" }, { 0x780b, 0xffff, 1, 1, "3DSTATE_VF_STATISTICS" }, { 0x780d, 0x00ff, 4, 4, "3DSTATE_VIEWPORT_STATE_POINTERS" }, - { 0x780e, 0xffff, 4, 4, NULL, 6, gen6_3DSTATE_CC_STATE_POINTERS }, - { 0x780e, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_CC_STATE_POINTERS }, + { 0x780e, 0xffff, 4, 4, "", 6, gen6_3DSTATE_CC_STATE_POINTERS }, + { 0x780e, 0x00ff, 2, 2, "", 7, gen7_3DSTATE_CC_STATE_POINTERS }, { 0x780f, 0x00ff, 2, 2, "3DSTATE_SCISSOR_POINTERS" }, { 0x7810, 0x00ff, 6, 6, "3DSTATE_VS" }, { 0x7811, 0x00ff, 7, 7, "3DSTATE_GS" }, @@ -3194,10 +3194,10 @@ decode_3d_965(struct drm_intel_decode *ctx) { 0x781e, 0x00ff, 3, 3, "3DSTATE_STREAMOUT" }, { 0x781f, 0x00ff, 14, 14, "3DSTATE_SBE" }, { 0x7820, 0x00ff, 8, 8, "3DSTATE_PS" }, - { 0x7821, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP }, - { 0x7823, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_VIEWPORT_STATE_POINTERS_CC }, - { 0x7824, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_BLEND_STATE_POINTERS }, - { 0x7825, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS }, + { 0x7821, 0x00ff, 2, 2, "", 7, gen7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP }, + { 0x7823, 0x00ff, 2, 2, "", 7, gen7_3DSTATE_VIEWPORT_STATE_POINTERS_CC }, + { 0x7824, 0x00ff, 2, 2, "", 7, gen7_3DSTATE_BLEND_STATE_POINTERS }, + { 0x7825, 0x00ff, 2, 2, "", 7, gen7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS }, { 0x7826, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_VS" }, { 0x7827, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_HS" },