From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot0-f200.google.com (mail-ot0-f200.google.com [74.125.82.200]) by kanga.kvack.org (Postfix) with ESMTP id 2FBA56B0069 for ; Fri, 19 Jan 2018 17:53:28 -0500 (EST) Received: by mail-ot0-f200.google.com with SMTP id h8so2004811ote.8 for ; Fri, 19 Jan 2018 14:53:28 -0800 (PST) Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id e14sor3890966oih.175.2018.01.19.14.53.27 for (Google Transport Security); Fri, 19 Jan 2018 14:53:27 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <20180119221243.GL13338@ZenIV.linux.org.uk> References: <201801172008.CHH39543.FFtMHOOVSQJLFO@I-love.SAKURA.ne.jp> <201801181712.BFD13039.LtHOSVMFJQFOFO@I-love.SAKURA.ne.jp> <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> From: Linus Torvalds Date: Fri, 19 Jan 2018 14:53:25 -0800 Message-ID: Subject: Re: [mm 4.15-rc8] Random oopses under memory pressure. Content-Type: text/plain; charset="UTF-8" Sender: owner-linux-mm@kvack.org List-ID: To: Al Viro 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 On Fri, Jan 19, 2018 at 2:12 PM, Al Viro wrote: > On Fri, Jan 19, 2018 at 10:42:18AM -0800, Linus Torvalds wrote: >> >> We *should* be careful about it. I guess sparse could be made to warn, >> but I'm afraid that we have so many of these things that a warning >> isn't reasonable. > > You mean like -Wptr-subtraction-blows? Heh. Apparently I already did that trivial warning back in 2005. I'd forgotten about it. > FWIW, allmodconfig on amd64 with C=2 CF=-Wptr-subtraction-blows is not too large > > IOW it's not terribly noisy. Might be an interesting idea to teach sparse to > print the type in question... Aha - with > > --- a/evaluate.c > +++ b/evaluate.c > @@ -848,7 +848,8 @@ static struct symbol *evaluate_ptr_sub(struct expression *expr) > > if (value & (value-1)) { > if (Wptr_subtraction_blows) > - warning(expr->pos, "potentially expensive pointer subtraction"); > + warning(expr->pos, "[%s] potentially expensive pointer subtraction", > + show_typename(lbase)); > } > > sub->op = '-'; > > we get things like > drivers/gpu/drm/i915/i915_gem_execbuffer.c:435:17: warning: [struct drm_i915_gem_exec_object2] potentially expensive pointer subtraction 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. 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". Linus -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org