From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D305BECAAD4 for ; Tue, 30 Aug 2022 22:05:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F90F8000E; Tue, 30 Aug 2022 18:05:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 581F08D0001; Tue, 30 Aug 2022 18:05:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3FA7C8000E; Tue, 30 Aug 2022 18:05:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 2AD728D0001 for ; Tue, 30 Aug 2022 18:05:55 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id EC84CC054A for ; Tue, 30 Aug 2022 22:05:54 +0000 (UTC) X-FDA: 79857642228.04.972BDE7 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 7168440040 for ; Tue, 30 Aug 2022 22:05:53 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5BA6360DDD; Tue, 30 Aug 2022 22:05:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82260C433C1; Tue, 30 Aug 2022 22:05:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1661897151; bh=WOPgq+Z/r2IfhVRD2klqGuqRjEDudKtBpcud8vKpYyk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=zdXxZEBCZRcSQbBODbQg04Xw1/vZ3ciEnmFehxiWEF9sP0bmdQi+HvP5hDPG6qpEG Aciuz/LdL6sL1fVQF+PrbGmgBwvb4MeIaVKdSjmfxM0J8XNXZtEjXvXATt6jdJvOmb gZvO0kFonCFekXOatC4xxsTJqBFa894ckXQui73o= Date: Tue, 30 Aug 2022 15:05:49 -0700 From: Andrew Morton To: Alexander Potapenko , Yu Zhao Cc: Marco Elver , Alexander Viro , Alexei Starovoitov , Andrey Konovalov , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Christoph Hellwig , Christoph Lameter , David Rientjes , Dmitry Vyukov , Eric Dumazet , Greg Kroah-Hartman , Herbert Xu , Ilya Leoshkevich , Ingo Molnar , Jens Axboe , Joonsoo Kim , Kees Cook , Mark Rutland , Matthew Wilcox , "Michael S. Tsirkin" , Pekka Enberg , Peter Zijlstra , Petr Mladek , Steven Rostedt , Thomas Gleixner , Vasily Gorbik , Vegard Nossum , Vlastimil Babka , kasan-dev , Linux Memory Management List , Linux-Arch , LKML Subject: Re: [PATCH v5 04/44] x86: asm: instrument usercopy in get_user() and put_user() Message-Id: <20220830150549.afa67340c2f5eb33ff9615f4@linux-foundation.org> In-Reply-To: References: <20220826150807.723137-1-glider@google.com> <20220826150807.723137-5-glider@google.com> <20220826211729.e65d52e7919fee5c34d22efc@linux-foundation.org> <20220829122452.cce41f2754c4e063f3ae8b75@linux-foundation.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661897153; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EsbLKIYTJSreJOGprEFnEf3JNlSaWAcAhph4+iue+0g=; b=hBzN1P58nYi9V5dgLPQaWhbJhAwtOUl79bN9xjU8kNdtDVHAmL3Id++5tABjizKudM5w2p aLaR2pOoUBhLX03m6AeIg2y9FSL2MYTKzW3IzZhJGLmmQsbs/IGyFqwU3Tjvh7FdmSSEHX J+9tlQQoRntjxFcvuaXyK1oJlSVPodM= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=zdXxZEBC; spf=pass (imf12.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661897153; a=rsa-sha256; cv=none; b=bKp0VPD2Nmyeoyupw3svoOBYSNE52ieOw5oTK99CgX76ePx/lLJY/L4Oau5IR7jwRK5Q2j +v7CgZqXYLyVBiD/bEKNvzCQ3/LOadNCG69lrAqbO31QpIK5dnTDq1O8c0q6F72gmcXf+n NiXFTN90OE6+ABB7i7CgIcwglyxa3eg= Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=zdXxZEBC; spf=pass (imf12.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Stat-Signature: ipr5ihupcwzkypqpzhg3a6ukusk6bu5h X-Rspamd-Queue-Id: 7168440040 X-Rspam-User: X-Rspamd-Server: rspam03 X-HE-Tag: 1661897153-781698 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: On Tue, 30 Aug 2022 16:23:44 +0200 Alexander Potapenko wrote: > > from init/do_mounts.c:2: > > ./include/linux/page-flags.h: In function ‘page_fixed_fake_head’: > > ./include/linux/page-flags.h:226:36: error: invalid use of undefined type ‘const struct page’ > > 226 | test_bit(PG_head, &page->flags)) { > > | ^~ > > ./include/linux/bitops.h:50:44: note: in definition of macro ‘bitop’ > > 50 | __builtin_constant_p((uintptr_t)(addr) != (uintptr_t)NULL) && \ > > | ^~~~ > > ./include/linux/page-flags.h:226:13: note: in expansion of macro ‘test_bit’ > > 226 | test_bit(PG_head, &page->flags)) { > > | ^~~~~~~~ > > ... > > Gotcha, this is a circular dependency: mm_types.h -> sched.h -> > kmsan.h -> gfp.h -> mmzone.h -> page-flags.h -> mm_types.h, where the > inclusion of sched.h into mm_types.h was only introduced in "mm: > multi-gen LRU: support page table walks" - that's why the problem was > missing in other trees. Ah, thanks for digging that out. Yu, that inclusion is regrettable. I don't think mm_types.h is an appropriate site for implementing lru_gen_use_mm() anyway. Adding a new header is always the right fix for these things. I'd suggest adding a new mglru.h (or whatever) and putting most/all of the mglru material in there. Also, the addition to kernel/sched/core.c wasn't clearly changelogged, is uncommented and I doubt if the sched developers know about it, let alone reviewed it. Please give them a heads-up. The addition looks fairly benign, but core context_switch() is the sort of thing which people get rather defensive about and putting mm-specific stuff in there might be challenged. Some quantitative justification of this optimization would be appropriate. > In fact sched.h only needs the definitions of `struct > kmsan_context_state` and `struct kmsan_ctx` from kmsan.h, so I am > splitting them off into kmsan_types.h to break this circle. > Doing so also helped catch a couple of missing/incorrect inclusions of > KMSAN headers in subsystems.