From patchwork Thu Mar 1 15:26:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 130254 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp2947259edc; Thu, 1 Mar 2018 07:34:19 -0800 (PST) X-Google-Smtp-Source: AG47ELsUl9xi+F3XgTeYRiw0ck+l43DSWMY5xdPtgMzkWCF+CpUkHBAp2HabsqeyLGxgTN0nSpkK X-Received: by 10.99.122.70 with SMTP id j6mr493665pgn.17.1519918459006; Thu, 01 Mar 2018 07:34:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519918459; cv=none; d=google.com; s=arc-20160816; b=0/ZTP6iCy3d+eMaF6aZxY68LCFyb6AZgaM+utNbhpZk2BuQGhAF9W80OJSOBLyGkaB jemDWMSLat8pP6s5LfxtQXIi5bVCV4aFJPBk717+yOKVOqH1JsN/zpskUo/3pZxY2Hdk ErlzFDQW+pjp0Ke2fz37A2Ex9HYgLHsHjPWDz+ZB1R9JUL4htYsJMQbR56YpJEP2uCC+ YlpmjaYS38pVPPgs2oPrbbE4iWgPHrF7jycbSlbgZlH2otzR8UR2EIiHwAwRaE1uYMGT j06lMp4pEEXBsXcaqGLes0nRwgZ0gri7HFzNQ7Z8vPXUE3tlAiU6k9EndRPTaxCOCgBZ i8Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=qRMZTHOPkyuNu+Z7MltVXp2sZ28UeJZ7b4MIMkT0Aow=; b=GspBwjta2Ni2LWwHKBOrxV8tTptz1jI8X3W9dtiYzTSyWJSmOqhFia4AFqVlZqNzNL zvaIGHKZuMpEYCDL2pswauj+KPxDymMQj3e1vee/siZ1PuMMP/qdyvGehRq97LtQrZDf ft1BkXM9MceU1RAr/4d/z2t7wKhMMj59SpocXON2T+iIcv2SpjNlTAQDBa/DRFX338eQ lvhY5cYm6ib6SUQ8RssBD2JSVgvW8Mg+THoz9HSEVLST79EqHlNkrs7S06XfLTwEke9W 0BUi0uQGmsptyXSWK2CPgBm7B2WcoV9WXfe5KAaaCTwyT47LBPyJjcHIxhfn8fwhAARh WPHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=GwfyDDdg; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s125si3214782pfb.37.2018.03.01.07.34.18; Thu, 01 Mar 2018 07:34:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=GwfyDDdg; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032416AbeCAPeQ (ORCPT + 10 others); Thu, 1 Mar 2018 10:34:16 -0500 Received: from mail-co1nam03on0135.outbound.protection.outlook.com ([104.47.40.135]:48864 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032404AbeCAPeH (ORCPT ); Thu, 1 Mar 2018 10:34:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=qRMZTHOPkyuNu+Z7MltVXp2sZ28UeJZ7b4MIMkT0Aow=; b=GwfyDDdgm/fpSoSNMoIqdQOs4F4iLydUf5CZ6WV66SgZQspqeBgch1bMDso1STf9MjdCv65HnZQjOP+ssSULblcBKLJ5CMgHF9tGD9jWbdZ4QfQxsXzy8YPTdy4dxoaiNpbz73DOdXL5mZ3UnhSYSUqcUlolg3MMBixzFoVyJZw= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0869.namprd21.prod.outlook.com (10.167.110.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.2; Thu, 1 Mar 2018 15:34:03 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446%2]) with mapi id 15.20.0567.006; Thu, 1 Mar 2018 15:34:03 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Arnd Bergmann , Boris Brezillon , Sasha Levin Subject: [added to the 4.1 stable tree] mtd: cfi: convert inline functions to macros Thread-Topic: [added to the 4.1 stable tree] mtd: cfi: convert inline functions to macros Thread-Index: AQHTsXGavtGavNDXLkmzpOamQbZrFw== Date: Thu, 1 Mar 2018 15:26:00 +0000 Message-ID: <20180301152116.1486-324-alexander.levin@microsoft.com> References: <20180301152116.1486-1-alexander.levin@microsoft.com> In-Reply-To: <20180301152116.1486-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DM5PR2101MB0869; 7:MR6nyLVXp8NtqzZ+pbXDrmrllo2J2z8lRH/bbnCS701+Zgn3HVegoGf+lI/erYUI8cxIcuUGmECMoYZlL06lBYkyFZfEk2SYP3JIgRbaeZ96/bVq/RJ0qyHETtGtaX7J9o2WLDkim8H0UxuqAcvO6RiMU+khMT4d8m20vsd3x7Ls5wzAEcoRuetuaXjKk1362acRU1YgrP2PsvptnZS/mDeIWiE/IzYXyxiVSZ3MjQm5ARZrXBOC0j6rfwmu+4n4 x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: b4e60432-6ff9-478f-8182-08d57f89dcef x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7193020); SRVR:DM5PR2101MB0869; x-ms-traffictypediagnostic: DM5PR2101MB0869: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(22074186197030)(89211679590171)(9452136761055)(183786458502308)(58145275503218); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(61425038)(6040501)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3231220)(944501227)(52105095)(3002001)(6055026)(61426038)(61427038)(6041288)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(6072148)(201708071742011); SRVR:DM5PR2101MB0869; BCL:0; PCL:0; RULEID:; SRVR:DM5PR2101MB0869; x-forefront-prvs: 05986C03E0 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(366004)(39380400002)(39860400002)(376002)(346002)(199004)(189003)(99286004)(10090500001)(8676002)(105586002)(81166006)(81156014)(68736007)(22452003)(3660700001)(305945005)(7736002)(2501003)(107886003)(5250100002)(2900100001)(8936002)(66066001)(106356001)(478600001)(10290500003)(6436002)(2906002)(76176011)(72206003)(36756003)(6506007)(316002)(86362001)(102836004)(97736004)(3280700002)(6512007)(14454004)(966005)(5660300001)(6486002)(6306002)(86612001)(186003)(53936002)(4326008)(25786009)(2950100002)(1076002)(110136005)(26005)(6346003)(54906003)(3846002)(6116002)(22906009); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB0869; H:DM5PR2101MB1032.namprd21.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: C14U5fVI3lssHPY+tbZ+SlUaieWJ/UWn5rrDybT1gmoDoXx5Ymg6L5M0ypk6lywAzI9ttTlEO1cqSpkM/6vxQuY72kk8u8HE2ALqZ8fBx/YqzimsHZJxzNd1SSap+8PJ+kM+IrwTjToh/akpZ20fz2D3aWzQN4JcnDDY+mjA+us= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: b4e60432-6ff9-478f-8182-08d57f89dcef X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Mar 2018 15:26:00.9743 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0869 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Arnd Bergmann This patch has been added to the 4.1 stable tree. If you have any objections, please let us know. -- 2.14.1 =============== [ Upstream commit 9e343e87d2c4c707ef8fae2844864d4dde3a2d13 ] The map_word_() functions, dating back to linux-2.6.8, try to perform bitwise operations on a 'map_word' structure. This may have worked with compilers that were current then (gcc-3.4 or earlier), but end up being rather inefficient on any version I could try now (gcc-4.4 or higher). Specifically we hit a problem analyzed in gcc PR81715 where we fail to reuse the stack space for local variables. This can be seen immediately in the stack consumption for cfi_staa_erase_varsize() and other functions that (with CONFIG_KASAN) can be up to 2200 bytes. Changing the inline functions into macros brings this down to 1280 bytes. Without KASAN, the same problem exists, but the stack consumption is lower to start with, my patch shrinks it from 920 to 496 bytes on with arm-linux-gnueabi-gcc-5.4, and saves around 1KB in .text size for cfi_cmdset_0020.c, as it avoids copying map_word structures for each call to one of these helpers. With the latest gcc-8 snapshot, the problem is fixed in upstream gcc, but nobody uses that yet, so we should still work around it in mainline kernels and probably backport the workaround to stable kernels as well. We had a couple of other functions that suffered from the same gcc bug, and all of those had a simpler workaround involving dummy variables in the inline function. Unfortunately that did not work here, the macro hack was the best I could come up with. It would also be helpful to have someone to a little performance testing on the patch, to see how much it helps in terms of CPU utilitzation. Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 Cc: stable@vger.kernel.org Signed-off-by: Arnd Bergmann Acked-by: Richard Weinberger Signed-off-by: Boris Brezillon Signed-off-by: Sasha Levin --- include/linux/mtd/map.h | 130 +++++++++++++++++++++++------------------------- 1 file changed, 61 insertions(+), 69 deletions(-) diff --git a/include/linux/mtd/map.h b/include/linux/mtd/map.h index dfff2baf836b..0deabc012551 100644 --- a/include/linux/mtd/map.h +++ b/include/linux/mtd/map.h @@ -265,75 +265,67 @@ void map_destroy(struct mtd_info *mtd); #define INVALIDATE_CACHED_RANGE(map, from, size) \ do { if (map->inval_cache) map->inval_cache(map, from, size); } while (0) - -static inline int map_word_equal(struct map_info *map, map_word val1, map_word val2) -{ - int i; - - for (i = 0; i < map_words(map); i++) { - if (val1.x[i] != val2.x[i]) - return 0; - } - - return 1; -} - -static inline map_word map_word_and(struct map_info *map, map_word val1, map_word val2) -{ - map_word r; - int i; - - for (i = 0; i < map_words(map); i++) - r.x[i] = val1.x[i] & val2.x[i]; - - return r; -} - -static inline map_word map_word_clr(struct map_info *map, map_word val1, map_word val2) -{ - map_word r; - int i; - - for (i = 0; i < map_words(map); i++) - r.x[i] = val1.x[i] & ~val2.x[i]; - - return r; -} - -static inline map_word map_word_or(struct map_info *map, map_word val1, map_word val2) -{ - map_word r; - int i; - - for (i = 0; i < map_words(map); i++) - r.x[i] = val1.x[i] | val2.x[i]; - - return r; -} - -static inline int map_word_andequal(struct map_info *map, map_word val1, map_word val2, map_word val3) -{ - int i; - - for (i = 0; i < map_words(map); i++) { - if ((val1.x[i] & val2.x[i]) != val3.x[i]) - return 0; - } - - return 1; -} - -static inline int map_word_bitsset(struct map_info *map, map_word val1, map_word val2) -{ - int i; - - for (i = 0; i < map_words(map); i++) { - if (val1.x[i] & val2.x[i]) - return 1; - } - - return 0; -} +#define map_word_equal(map, val1, val2) \ +({ \ + int i, ret = 1; \ + for (i = 0; i < map_words(map); i++) \ + if ((val1).x[i] != (val2).x[i]) { \ + ret = 0; \ + break; \ + } \ + ret; \ +}) + +#define map_word_and(map, val1, val2) \ +({ \ + map_word r; \ + int i; \ + for (i = 0; i < map_words(map); i++) \ + r.x[i] = (val1).x[i] & (val2).x[i]; \ + r; \ +}) + +#define map_word_clr(map, val1, val2) \ +({ \ + map_word r; \ + int i; \ + for (i = 0; i < map_words(map); i++) \ + r.x[i] = (val1).x[i] & ~(val2).x[i]; \ + r; \ +}) + +#define map_word_or(map, val1, val2) \ +({ \ + map_word r; \ + int i; \ + for (i = 0; i < map_words(map); i++) \ + r.x[i] = (val1).x[i] | (val2).x[i]; \ + r; \ +}) + +#define map_word_andequal(map, val1, val2, val3) \ +({ \ + int i, ret = 1; \ + for (i = 0; i < map_words(map); i++) { \ + if (((val1).x[i] & (val2).x[i]) != (val2).x[i]) { \ + ret = 0; \ + break; \ + } \ + } \ + ret; \ +}) + +#define map_word_bitsset(map, val1, val2) \ +({ \ + int i, ret = 0; \ + for (i = 0; i < map_words(map); i++) { \ + if ((val1).x[i] & (val2).x[i]) { \ + ret = 1; \ + break; \ + } \ + } \ + ret; \ +}) static inline map_word map_word_load(struct map_info *map, const void *ptr) {