Received: by 10.213.65.68 with SMTP id h4csp1215413imn; Wed, 4 Apr 2018 14:55:11 -0700 (PDT) X-Google-Smtp-Source: AIpwx49MwwKPobQd0ax5LSQ+9szfgF5jk8ur9mfjuU5bJirtG0SjHXgutQ6TDuAMCs+bzAUoBBh+ X-Received: by 10.101.100.89 with SMTP id s25mr12697390pgv.401.1522878911713; Wed, 04 Apr 2018 14:55:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522878911; cv=none; d=google.com; s=arc-20160816; b=TNQI0YbWwwQVISxZq0/wIq+BOdrSaJyw10vZYrygR2hdJGXKuTq21Q4Xp1vzynNisb 5P7cgdp9jFOOQ7iqtFF/84S6X0T0oikX3BWkdCzm3kJ+Z7+5S6/k4wRfqd2YpEYH8XIk 2zAo4Mptk342qo/wWoHGhm4zCn/QdgBPfO5adBbh+AzCqMlRSoS5YQTFE1w6/HQs0R29 dfl3Zd3uCrdqcwQw4he9kj2tDEKqcGjTkooTg8HxaQsjmYpV2biDsxuJWe0RtA8iofoR PgiLhNBAzCVeYDScKMN5pvmLEDga6OnYA3BZWMsUOeOdmyDQcpnWb6CXxoB5XFc4ash8 wzpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=UPSuVQC2NxkDOi9R1SJVBAR6PqcS/HjBcudo+sjQH3c=; b=0GsshT4eiNTU30iY9J2B3CguVE9dbqH9l/YFiwUkxiH2GlAwnWwFkRyteQuy/+ZRqu 14KXMKU+XP4rh07A+ErM8QSkyy4EBKGGKY/x8AFSJ5YUh4qzfMcsb3LGhp4G3HjeVNIU I+Egb8sxvqkFOebQPq/COXhCPilEaOX6FFggS7wk1jzrt/kntXm3mq9s+2xTJQhiHnO2 OIEM6HyXXewtZ7H2NK1bG0d8PvyQA1lxDviRTNyuAeYMvr3EX00jL3U5QfmehuYSJbXf GJXRNLa9tC44QzrRJnei/NLFEtmKN2H8XMbArxEGIqyizAF+8Gn4dbLUiRyjcko5wSWl XO8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rQKzMw6I; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w13-v6si2116452plq.357.2018.04.04.14.54.57; Wed, 04 Apr 2018 14:55:11 -0700 (PDT) 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; dkim=pass header.i=@google.com header.s=20161025 header.b=rQKzMw6I; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752264AbeDDVxz (ORCPT + 99 others); Wed, 4 Apr 2018 17:53:55 -0400 Received: from mail-pl0-f48.google.com ([209.85.160.48]:41374 "EHLO mail-pl0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752171AbeDDVxy (ORCPT ); Wed, 4 Apr 2018 17:53:54 -0400 Received: by mail-pl0-f48.google.com with SMTP id bj1-v6so13631924plb.8 for ; Wed, 04 Apr 2018 14:53:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=UPSuVQC2NxkDOi9R1SJVBAR6PqcS/HjBcudo+sjQH3c=; b=rQKzMw6I5v0xHOfpjQq0F1hDljBe7tRp07cq+h/p+MdFYsHeTW010xwwsl4hi4amdW roTTwNoWRUegrMvgkyRIGindr6E4DD6jYr9QoWmo9/WBAR6CXh3wWpoNrEVuT2tgn/cN /9k2/AteybZlf//kwJMn43+JVFOTR67tG3aE/agRlAufOHK/abB+hDaNuV1sXh5rxR6/ NarWSQXvQAMePEz2vbM03tQef58edWGpH3x+c+KcdxIJUYN/8iyBny6eTlhCilmyPcPD nERjWRwUavLt7Hav3mytH/x4/j/u1iRHsjSnO2PmjdjAomlTftKzVkcu9yY2quftWS1i D5Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=UPSuVQC2NxkDOi9R1SJVBAR6PqcS/HjBcudo+sjQH3c=; b=igSCmDM7Mr52YkgZC5uS6ds1rUS8oI9VogK8WMaLb3KWyXtrjaThNLdhS4sKFiHmYD PTBhNHFfo+eig4Aivch+EO1PVfU/h2U21yezZXpYVRKxDEdd7sTuiywFQPrEzNjzL+GA 4oy5AWQBgDCrbhRfb46cZAyFUqWk+0DHzPM34Fq4cQPHDuWrz7s0HS4URL6UijckDw73 7QbuyKDRXlrpek2hLWlWc6Wj5DdX1pnCdPuQjKY0AZH9YxBgLop2dIqZzXkurlp+wtBT 6pEIS2RkZciwQ+eD4baDc10fSUhLLnZsBcFd2ZYcuA+pY8QLVIu7AdkGCp7Mhhr0wg/i qi+g== X-Gm-Message-State: AElRT7HVcfa79Lssjt0CtuTE3inKl6UL3+cxCXhpnANJSggK6Bzfi9A4 qGcl6Z0P8eISUpVGDxVegr2Baw== X-Received: by 10.98.153.204 with SMTP id t73mr15141490pfk.121.1522878833320; Wed, 04 Apr 2018 14:53:53 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id z127sm11381105pfb.72.2018.04.04.14.53.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Apr 2018 14:53:52 -0700 (PDT) Date: Wed, 4 Apr 2018 14:53:51 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Laurent Dufour cc: kernel test robot , paulmck@linux.vnet.ibm.com, peterz@infradead.org, akpm@linux-foundation.org, kirill@shutemov.name, ak@linux.intel.com, mhocko@kernel.org, dave@stgolabs.net, jack@suse.cz, Matthew Wilcox , benh@kernel.crashing.org, mpe@ellerman.id.au, paulus@samba.org, Thomas Gleixner , Ingo Molnar , hpa@zytor.com, Will Deacon , Sergey Senozhatsky , Andrea Arcangeli , Alexei Starovoitov , kemi.wang@intel.com, sergey.senozhatsky.work@gmail.com, Daniel Jordan , linux-kernel@vger.kernel.org, linux-mm@kvack.org, haren@linux.vnet.ibm.com, khandual@linux.vnet.ibm.com, npiggin@gmail.com, bsingharora@gmail.com, Tim Chen , linuxppc-dev@lists.ozlabs.org, x86@kernel.org, lkp@01.org Subject: Re: [mm] b1f0502d04: INFO:trying_to_register_non-static_key In-Reply-To: <147e8be3-2c33-2111-aacc-dc2bb932fa8c@linux.vnet.ibm.com> Message-ID: References: <20180317075119.u6yuem2bhxvggbz3@inn> <792c0f75-7e7f-cd81-44ae-4205f6e4affc@linux.vnet.ibm.com> <147e8be3-2c33-2111-aacc-dc2bb932fa8c@linux.vnet.ibm.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 4 Apr 2018, Laurent Dufour wrote: > > I also think the following is needed: > > > > diff --git a/fs/exec.c b/fs/exec.c > > --- a/fs/exec.c > > +++ b/fs/exec.c > > @@ -312,6 +312,10 @@ static int __bprm_mm_init(struct linux_binprm *bprm) > > vma->vm_flags = VM_SOFTDIRTY | VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP; > > vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); > > INIT_LIST_HEAD(&vma->anon_vma_chain); > > +#ifdef CONFIG_SPECULATIVE_PAGE_FAULT > > + seqcount_init(&vma->vm_sequence); > > + atomic_set(&vma->vm_ref_count, 0); > > +#endif > > > > err = insert_vm_struct(mm, vma); > > if (err) > > No, this not needed because the vma is allocated with kmem_cache_zalloc() so > vm_ref_count is 0, and insert_vm_struc() will later call > __vma_link_rb() which will call seqcount_init(). > > Furhtermore, in case of error, the vma structure is freed without calling > get_vma() so there is risk of lockdep warning. > Perhaps you're working from a different tree than I am, or you fixed the lockdep warning differently when adding to dup_mmap() and mmap_region(). I got the following two lockdep errors. I fixed it locally by doing the seqcount_init() and atomic_set() everywhere a vma could be initialized. INFO: trying to register non-static key. the code is fine but needs lockdep annotation. turning off the locking correctness validator. CPU: 12 PID: 1 Comm: init Not tainted Call Trace: [] dump_stack+0x67/0x98 [] register_lock_class+0x1e6/0x4e0 [] __lock_acquire+0xb9/0x1710 [] lock_acquire+0xba/0x200 [] mprotect_fixup+0x10f/0x310 [] setup_arg_pages+0x12d/0x230 [] load_elf_binary+0x44a/0x1740 [] search_binary_handler+0x9b/0x1e0 [] load_script+0x206/0x270 [] search_binary_handler+0x9b/0x1e0 [] do_execveat_common.isra.32+0x6b5/0x9d0 [] do_execve+0x2c/0x30 [] run_init_process+0x2b/0x30 [] kernel_init+0x54/0x110 [] ret_from_fork+0x3a/0x50 and INFO: trying to register non-static key. the code is fine but needs lockdep annotation. turning off the locking correctness validator. CPU: 21 PID: 1926 Comm: mkdir Not tainted Call Trace: [] dump_stack+0x67/0x98 [] register_lock_class+0x1e6/0x4e0 [] __lock_acquire+0xb9/0x1710 [] lock_acquire+0xba/0x200 [] unmap_page_range+0x89/0xaa0 [] unmap_single_vma+0x8f/0x100 [] unmap_vmas+0x4b/0x90 [] exit_mmap+0xa3/0x1c0 [] mmput+0x73/0x120 [] do_exit+0x2bd/0xd60 [] SyS_exit+0x17/0x20 [] do_syscall_64+0x6d/0x1a0 [] entry_SYSCALL_64_after_hwframe+0x26/0x9b I think it would just be better to generalize vma allocation to initialize certain fields and init both spf fields properly for CONFIG_SPECULATIVE_PAGE_FAULT. It's obviously too delicate as is.