Received: by 10.223.176.46 with SMTP id f43csp301755wra; Fri, 19 Jan 2018 18:07:06 -0800 (PST) X-Google-Smtp-Source: AH8x227qA+dK/H57/lEFBQxCpLqNlGhq4k2vrLUfR1BlpESbPekWaKVEjlD9XFbtVI8aQPvwIZsh X-Received: by 10.99.61.143 with SMTP id k137mr485483pga.315.1516414026442; Fri, 19 Jan 2018 18:07:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516414026; cv=none; d=google.com; s=arc-20160816; b=v/oWxFzy13sFMsHeVOLWJ8sK4/putGApzBVji24tE35UWUhXvIEyeNyPuCb9NU2i6s L70raGxrIVrByHkCocfnQ70kduqd+fJ4dDGQcm+fYl+ptulozZ3hBgeMasBdmrZl7F9W AbQ3PTrbW9Suo0ccB0DH4xcMuV1B+tQRD9xQqEE719c0u+HL0MlLxPm2qhk1PTFbkLgn LUFvoCnvjgnaAMljCUw+kI4gvwTXdN3rCdXaF1XmD0XZrTkrgNNB7OKH9203vMUz8Hr+ tHNeOyCioGodiEiQq8Wm08XG4mKKQ9Uelx3i81EXGa+cgu3YVFl48k0Ui7VMdJDwSKnd 4UZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=4M2Aszb3E/S38Fern20ILeK3zL+eUnmmJ9yNTo/s0KM=; b=OwoAO0HpgW47BlZKSsaIAqm/tGV4VnhBFBxKJyBVGMf0Dy4Kd0Of+ACUM97gEgQyvF +JWauvGOTjI4cebIGOilnmeDAnw2ICGOiDlLQjel5RaGOSNitFmDz70IzFyxe0xuKUTd TG7SgpxT2UKbJMxnGhfma1v5DScipSx1qFe31RX/PcPaOdKS+Ox6zWHsyLgwXw7q5qus Aa8A8cS8DEHYCeUDN3tUb1Dg9sMZFep7LXTh9RyLgLf04uf10/djgt8U4J+50hZdps3Q 0q53INveBTi/8Svoa9PHKNQBCevFrnZ3R5SGOe/PZCuOY6AEX+1D8clbR53U9+5MqX/i TtyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a9si9089618pff.55.2018.01.19.18.06.52; Fri, 19 Jan 2018 18:07:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756257AbeATCGB (ORCPT + 99 others); Fri, 19 Jan 2018 21:06:01 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:38782 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754766AbeATCF5 (ORCPT ); Fri, 19 Jan 2018 21:05:57 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1eciUQ-0005R2-0V; Sat, 20 Jan 2018 02:02:38 +0000 Date: Sat, 20 Jan 2018 02:02:37 +0000 From: Al Viro To: Linus Torvalds Cc: Matthew Wilcox , "Kirill A. Shutemov" , Peter Zijlstra , Andrea Arcangeli , Dave Hansen , Tetsuo Handa , "Kirill A. Shutemov" , Andrew Morton , Johannes Weiner , Joonsoo Kim , Mel Gorman , Tony Luck , Vlastimil Babka , Michal Hocko , "hillf.zj" , Hugh Dickins , Oleg Nesterov , Rik van Riel , Srikar Dronamraju , Vladimir Davydov , Ingo Molnar , Linux Kernel Mailing List , linux-mm , the arch/x86 maintainers Subject: Re: [mm 4.15-rc8] Random oopses under memory pressure. Message-ID: <20180120020237.GM13338@ZenIV.linux.org.uk> References: <20180118122550.2lhsjx7hg5drcjo4@node.shutemov.name> <20180118145830.GA6406@redhat.com> <20180118165629.kpdkezarsf4qymnw@node.shutemov.name> <20180118234955.nlo55rw2qsfnavfm@node.shutemov.name> <20180119125503.GA2897@bombadil.infradead.org> <20180119221243.GL13338@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 19, 2018 at 02:53:25PM -0800, Linus Torvalds wrote: > It would probably be good to add the size too, just to explain why > it's potentially expensive. > > That said, apparently we do have hundreds of them, with just > cpufreq_frequency_table having a ton. Maybe some are hidden in macros > and removing one removes a lot. cpufreq_table_find_index_...(), mostly. > The real problem is that sometimes the subtraction is simply the right > thing to do, and there's no sane way to say "yeah, this is one of > those cases you shouldn't warn about". FWIW, the sizes of the most common ones are 91 sizeof struct cpufreq_frequency_table = 12 Almost all of those come from cpufreq_for_each_valid_entry(pos, table) if (....) return pos - table; and I wonder if we would be better off with something like #define cpufreq_for_each_valid_entry(pos, table, idx) \ for (pos = table, idx = 0; pos->frequency != CPUFREQ_TABLE_END; pos++, idx++) \ if (pos->frequency == CPUFREQ_ENTRY_INVALID) \ continue; \ else so that those loops would become cpufreq_for_each_valid_entry(pos, table, idx) if (....) return idx; 36 sizeof struct Indirect = 24 21 sizeof struct ips_scb = 216 18 sizeof struct runlist_element = 24 13 sizeof struct zone = 1728 Some are from #define zone_idx(zone) ((zone) - (zone)->zone_pgdat->node_zones) but there's static inline int zone_id(const struct zone *zone) { struct pglist_data *pgdat = zone->zone_pgdat; return zone - pgdat->node_zones; } and a couple of places where we have for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) { Those bloody well ought to be for (zone = node_zones, end = node_zones + MAX_NR_ZONES; zone < end; zone++) { 13 sizeof struct vring = 40 11 sizeof struct usbhsh_device = 24 10 sizeof struct xpc_partition = 888 9 sizeof struct skge_element = 40 9 sizeof struct lock_class = 400 9 sizeof struct hstate = 29872 That little horror comes from get_hstate_idx() and hstate_index(). Code generated for division is movabsq $-5542915600080909725, %rax sarq $4, %rdi imulq %rdi, %rax 7 sizeof struct nvme_rdma_queue = 312 7 sizeof struct iso_context = 208 6 sizeof struct i915_power_well = 48 6 sizeof struct hpet_dev = 168 6 sizeof struct ext4_extent = 12 6 sizeof struct esas2r_target = 120 5 sizeof struct iio_chan_spec = 152 5 sizeof struct hwspinlock = 96 4 sizeof struct myri10ge_slice_state = 704 4 sizeof struct ext4_extent_idx = 12 Another interesting-looking one is struct vhost_net_virtqueue (18080 bytes) Note that those sizes are rather sensitive to lockdep, spinlock debugging, etc.