From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) by gnuweeb.org (Postfix) with ESMTPSA id 6CB89801E6 for ; Sun, 3 Jul 2022 12:24:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1656851080; bh=hWdSff/FKBXSjb9Ti/71PKNERWEenDdtJqRsU52OBHw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Ar4S4PVWJlE3CV1PYoMYWuH3snZoaspp/J8hoBMFQonHnVnE5jUMM1446vgDc3Krc YoNL+7/uMfUqZODmmZ3mjC21nEnRzJ9VEvaiLm2gWWrKmnmdaikBw/f0lOdtDtzb8M DvXVxp9bKtq+Yw0DW4lBR9yw/AvdKOtnXXhQQTjB0yEf7E4a+emRSTXdgET3DrlSmM gmar3spAxXSlrxFvtMbKGBUyKQ1LuruC/iZfpppV6z+Bwc2TVGTtWar8VqSG4Vdj2F ntICbZ3bXKKRWAGOe9SwqhUb4VA4FQwON8HNFGIQ5Mi4vj4/RMz2u0kgVYip56q7jR TwmjAhlroBqwA== Received: by mail-lj1-f180.google.com with SMTP id n15so7852976ljg.8 for ; Sun, 03 Jul 2022 05:24:40 -0700 (PDT) X-Gm-Message-State: AJIora//Gi74pZHWELgahLuNEMMRHcWpATkcqRMcU3lbY75ulQSQHtyB ZdOdHR0FUQL9vvcsv5TBwRVd0PReG2Ps6LAq2c4= X-Google-Smtp-Source: AGRyM1vD6HYy+WT+ogYFkZMeQAEt2/J/HDPzdsbcKScHvphamI7AfagCZvp+hYNifrhgzlMwddPYLhGuqAy8PNHzxXQ= X-Received: by 2002:a2e:a485:0:b0:25a:735c:9f41 with SMTP id h5-20020a2ea485000000b0025a735c9f41mr12839290lji.389.1656851078596; Sun, 03 Jul 2022 05:24:38 -0700 (PDT) MIME-Version: 1.0 References: <20220703115240.215695-1-ammar.faizi@intel.com> <20220703115240.215695-3-ammar.faizi@intel.com> In-Reply-To: <20220703115240.215695-3-ammar.faizi@intel.com> From: Alviro Iskandar Setiawan Date: Sun, 3 Jul 2022 19:24:27 +0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH liburing v1 2/2] setup: Mark the exported functions as __cold To: Ammar Faizi Cc: Jens Axboe , "Fernanda Ma'rouf" , Hao Xu , Pavel Begunkov , io-uring Mailing List , "GNU/Weeb Mailing List" Content-Type: text/plain; charset="UTF-8" List-Id: On Sun, Jul 3, 2022 at 6:59 PM Ammar Faizi wrote: > > From: Ammar Faizi > > These functions are called at initialization, which are slow-paths. > Mark them as __cold so that the compiler will optimize for code size. > > Here is the result compiling with Ubuntu clang > 15.0.0-++20220601012204+ec2711b35411-1~exp1~20220601012300.510 > > Without this patch: > > $ wc -c src/liburing.so.2.3 > 71288 src/liburing.so.2.3 > > With this patch: > > $ wc -c src/liburing.so.2.3 > 69448 src/liburing.so.2.3 > > Take one slow-path function example, using __cold avoids aggresive > inlining. > > Without this patch: > > 00000000000024f0 : > 24f0: pushq %r14 > 24f2: pushq %rbx > 24f3: subq $0x78,%rsp > 24f7: movq %rsi,%r14 > 24fa: xorps %xmm0,%xmm0 > 24fd: movaps %xmm0,(%rsp) > 2501: movaps %xmm0,0x60(%rsp) > 2506: movaps %xmm0,0x50(%rsp) > 250b: movaps %xmm0,0x40(%rsp) > 2510: movaps %xmm0,0x30(%rsp) > 2515: movaps %xmm0,0x20(%rsp) > 251a: movaps %xmm0,0x10(%rsp) > 251f: movq $0x0,0x70(%rsp) > 2528: movl %edx,0x8(%rsp) > 252c: movq %rsp,%rsi > 252f: movl $0x1a9,%eax > 2534: syscall > 2536: movq %rax,%rbx > 2539: testl %ebx,%ebx > 253b: js 256a > 253d: movq %rsp,%rsi > 2540: movl %ebx,%edi > 2542: movq %r14,%rdx > 2545: callq 2080 > 254a: testl %eax,%eax > 254c: je 255d > 254e: movl %eax,%edx > 2550: movl $0x3,%eax > 2555: movl %ebx,%edi > 2557: syscall > 2559: movl %edx,%ebx > 255b: jmp 256a > 255d: movl 0x14(%rsp),%eax > 2561: movl %eax,0xc8(%r14) > 2568: xorl %ebx,%ebx > 256a: movl %ebx,%eax > 256c: addq $0x78,%rsp > 2570: popq %rbx > 2571: popq %r14 > 2573: retq > > With this patch: > > 000000000000240c : > 240c: subq $0x78,%rsp > 2410: xorps %xmm0,%xmm0 > 2413: movq %rsp,%rax > 2416: movaps %xmm0,(%rax) > 2419: movaps %xmm0,0x60(%rax) > 241d: movaps %xmm0,0x50(%rax) > 2421: movaps %xmm0,0x40(%rax) > 2425: movaps %xmm0,0x30(%rax) > 2429: movaps %xmm0,0x20(%rax) > 242d: movaps %xmm0,0x10(%rax) > 2431: movq $0x0,0x70(%rax) > 2439: movl %edx,0x8(%rax) > 243c: movq %rax,%rdx > 243f: callq 2090 > 2444: addq $0x78,%rsp > 2448: retq > > Signed-off-by: Ammar Faizi Reviewed-by: Alviro Iskandar Setiawan tq -- Viro