Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965047AbbDUW5a (ORCPT ); Tue, 21 Apr 2015 18:57:30 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:36170 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932096AbbDUW52 (ORCPT ); Tue, 21 Apr 2015 18:57:28 -0400 Date: Wed, 22 Apr 2015 00:57:23 +0200 From: Hagen Paul Pfeifer To: Ingo Molnar Cc: Linus Torvalds , Borislav Petkov , "linux-kernel@vger.kernel.org" , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Peter Zijlstra , Andrew Morton Subject: Re: [PATCH RFC] x86: enforce inlining for atomics Message-ID: <20150421225723.GA5927@virgo.local> References: <1429565231-4609-1-git-send-email-hagen@jauu.net> <20150420215645.GC10191@pd.tnic> <20150421074212.GA25081@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150421074212.GA25081@gmail.com> X-Key-Id: 98350C22 X-Key-Fingerprint: 490F 557B 6C48 6D7E 5706 2EA2 4A22 8D45 9835 0C22 X-GPG-Key: gpg --recv-keys --keyserver wwwkeys.eu.pgp.net 98350C22 User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3067 Lines: 81 * Ingo Molnar | 2015-04-21 09:42:12 [+0200]: Hey Ingo, >So the thing is that allyesconfig turns on -Os: > > CONFIG_CC_OPTIMIZE_FOR_SIZE=y CONFIG_CC_OPTIMIZE_FOR_SIZE seems to have no effect, The only option which makes a difference is CONFIG_OPTIMIZE_INLINING! But this is not a big surprise: *disabling* CONFIG_OPTIMIZE_INLINING substitudes _all_ inlines with __attribute__((always_inline)). "If unsure, say N." -> results in configurations with always_inline. So I tested again, one time with unset CONFIG_OPTIMIZE_INLINING the result seems fine: show_temp: 59 duplicates char2uni: 52 duplicates uni2char: 52 duplicates sd_probe: 49 duplicates sd_driver_init: 48 duplicates sd_driver_exit: 48 duplicates usb_serial_module_exit: 47 duplicates [...] We see ordinary "template" reuse of common driver code without renaming the copied static's. But compiled with CONFIG_OPTIMIZE_INLINING=y the inlining is not respected by gcc: atomic_inc: 544 duplicates rcu_read_unlock: 453 duplicates rcu_read_lock: 383 duplicates get_dma_ops: 271 duplicates arch_local_irq_restore: 258 duplicates atomic_dec: 215 duplicates kzalloc: 185 duplicates test_and_set_bit: 156 duplicates cpumask_check: 148 duplicates cpumask_next: 146 duplicates list_del: 131 duplicates kref_get: 126 duplicates test_and_clear_bit: 122 duplicates brelse: 122 duplicates schedule_work: 122 duplicates netif_tx_stop_queue: 115 duplicates atomic_dec_and_test: 107 duplicates dma_mapping_error: 105 duplicates list_del_init: 101 duplicates netif_stop_queue: 100 duplicates arch_local_save_flags: 98 duplicates tasklet_schedule: 76 duplicates clk_prepare_enable: 71 duplicates init_completion: 69 duplicates pskb_may_pull: 67 duplicates [...] Again, the used gcc version is "gcc (Debian 4.9.2-10) 4.9.2". So it is not outdated nor a legacy one. The inline heuristic seems really broken for some parts. Is it possible that gcc is bedeviled because of inline assembler parts which brings confuse the internal scoring system? I suggest the following: I prepare a patch series for the most obvious candidates and substituting inline with __always_inline (probably ~50 functions). Each subsystem maintainer can check and ACK the patch. This has the benefit that for all other locations gcc is still responsible for inlining decision. Enforcing inlining via __always_inline for all inline marked function is probably too hard!? In 2015 gcc is still not able to inline single line statements - that's strange. Linus, ack? Hagen -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/