From patchwork Thu Jul 1 01:56:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12353393 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_RED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B0EBC11F68 for ; Thu, 1 Jul 2021 01:56:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E3A1061420 for ; Thu, 1 Jul 2021 01:56:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E3A1061420 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6881F8D0273; Wed, 30 Jun 2021 21:56:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 65EE98D024F; Wed, 30 Jun 2021 21:56:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 54DEA8D0273; Wed, 30 Jun 2021 21:56:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0084.hostedemail.com [216.40.44.84]) by kanga.kvack.org (Postfix) with ESMTP id 2B4338D024F for ; Wed, 30 Jun 2021 21:56:06 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id EBA6882E2339 for ; Thu, 1 Jul 2021 01:56:05 +0000 (UTC) X-FDA: 78312353490.11.7BCF6B7 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf18.hostedemail.com (Postfix) with ESMTP id 769854002087 for ; Thu, 1 Jul 2021 01:56:05 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id A505F61418; Thu, 1 Jul 2021 01:56:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1625104564; bh=rZZI2bnSbL3/duuUqmmIHxEEwnOkYYkO7iPqhrm/TQc=; h=Date:From:To:Subject:In-Reply-To:From; b=IE1qrrxv7cvAwCczh8zriRfwzdelO3pE4x55J83e0a41OSqESireQfnVQA0c8W7zv al0T8nu3oA/RIO/45f1fkU6Kd9bnhozqKa4O4VL4BslAYvC1Cz5m7OFG7rB87UWtsQ +pKuWb5GeXqfpkivcvN0+Sl95Fj81T98PODuLZtc= Date: Wed, 30 Jun 2021 18:56:04 -0700 From: Andrew Morton To: adobriyan@gmail.com, akpm@linux-foundation.org, linux-mm@kvack.org, mm-commits@vger.kernel.org, torvalds@linux-foundation.org Subject: [patch 168/192] lib: uninline simple_strtoull() Message-ID: <20210701015604.siv4k3Srj%akpm@linux-foundation.org> In-Reply-To: <20210630184624.9ca1937310b0dd5ce66b30e7@linux-foundation.org> User-Agent: s-nail v14.8.16 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=IE1qrrxv; spf=pass (imf18.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Stat-Signature: zoftpsi81f8z54xrfws46uioju75sj66 X-Rspamd-Queue-Id: 769854002087 X-Rspamd-Server: rspam06 X-HE-Tag: 1625104565-829271 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Alexey Dobriyan Subject: lib: uninline simple_strtoull() Gcc inlines simple_strtoull() too agressively. Given that all 4 signatures match, everything very efficiently calls or tailcalls into simple_strtoull(): ffffffff81da0240 : ffffffff81da0240: 80 3f 2d cmp BYTE PTR [rdi],0x2d ffffffff81da0243: 74 05 je ffffffff81da024a ffffffff81da0245: e9 76 ff ff ff jmp simple_strtoull ffffffff81da024a: 48 83 c7 01 add rdi,0x1 ffffffff81da024e: e8 6d ff ff ff call simple_strtoull ffffffff81da0253: 48 f7 d8 neg rax ffffffff81da0256: c3 ret Space savings (on F34-ish .config) add/remove: 0/0 grow/shrink: 1/3 up/down: 52/-313 (-261) Function old new delta vsscanf 2167 2219 +52 simple_strtoul 72 2 -70 simple_strtoll 143 23 -120 simple_strtol 143 20 -123 Link: https://lkml.kernel.org/r/YMO2zoOQk2eF34tn@localhost.localdomain Signed-off-by: Alexey Dobriyan Signed-off-by: Andrew Morton --- lib/vsprintf.c | 1 + 1 file changed, 1 insertion(+) --- a/lib/vsprintf.c~lib-uninline-simple_strtoull +++ a/lib/vsprintf.c @@ -61,6 +61,7 @@ * * This function has caveats. Please use kstrtoull instead. */ +noinline unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base) { unsigned long long result;