Received: by 10.213.65.68 with SMTP id h4csp2160356imn; Thu, 5 Apr 2018 09:59:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/u7Rm654Wz8Ar6F6BmU/UsBKuAsYpCeaoZeWbYk4AshmeShllF30I8Nf9BxZVPJUJRu9jW X-Received: by 10.101.87.138 with SMTP id b10mr15266790pgr.241.1522947548850; Thu, 05 Apr 2018 09:59:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522947548; cv=none; d=google.com; s=arc-20160816; b=EPX7hC2yM+oqgfq5y3DUIEOmyXprkMUsEL2n2XBmDFLnCcuFjCG2ElEtpRG0h2akKa RtwfHyBgmW0Pra3gKv/1WSRYHdZTynZ/Dcr5P9QxaAuJIZ20rsd38zxYMvA5cBL+1nqb Bod4pVr7eR0UalupVmH9l8xsqV8uWrCCtP1dNBK3JZwlXpQHWwv4lxaIDuuHuBZbUq20 ZUNmsFtfiWU4bCadqr/qsn5ul7ABcpvo1+kAwWa+y4ccRJL4UizHg3FTV2jxt6SPwVoN dsRk++G5A2lcUsKWlrR7Z8Coa2rn1bUwS7nb/3WQKfb+OnDZfDZ+XwNUk6G//foY0tiu txog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date:from :references:cc:to:subject:arc-authentication-results; bh=6/9F7+RrO05j90c0yuscr+g4eIPQB0mnItZ7hj2Vne4=; b=sJIRL5FFrXDuwcYzUivwjKadcuFNdr2L9braHZoJ0NZGrmkQvWBGN914MmnfdzztZV hGr5WUMpfwDMTbfilzT6TVrf+u0yAETAQoKqBjvz/E3/FquA+WrNBf6n+wX9HKoqkGOz Zh/axRZTbDGIhi8p3r1YLhg22cMIKd9bJcBEzGni7Olzun1zNBQeJ71K/FS03qBSyCWD H48QAXS3Xl/HygeogkvZwQSwW2e/c1ovcbsL6OD7731s4JPoTe/3i6Dq/5N+GFtjjhwb n92PJA4Awkeap9ToMURHCEH/puKiDyhtujNrFtH9HoV6BCqMCXNKvtWfGv69kr5jOBTg l9wQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i10si5567436pgq.363.2018.04.05.09.58.54; Thu, 05 Apr 2018 09:59:08 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751447AbeDEQ5N (ORCPT + 99 others); Thu, 5 Apr 2018 12:57:13 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:44342 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750726AbeDEQ5L (ORCPT ); Thu, 5 Apr 2018 12:57:11 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w35Gv2Ye013429 for ; Thu, 5 Apr 2018 12:57:10 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 2h5nhg77y6-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Thu, 05 Apr 2018 12:57:07 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 5 Apr 2018 17:55:45 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 5 Apr 2018 17:55:37 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w35GtaM753739696; Thu, 5 Apr 2018 16:55:36 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 427F8AE045; Thu, 5 Apr 2018 17:45:41 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 12232AE053; Thu, 5 Apr 2018 17:45:40 +0100 (BST) Received: from [9.101.4.33] (unknown [9.101.4.33]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 5 Apr 2018 17:45:40 +0100 (BST) Subject: Re: [mm] b1f0502d04: INFO:trying_to_register_non-static_key To: David Rientjes 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 References: <20180317075119.u6yuem2bhxvggbz3@inn> <792c0f75-7e7f-cd81-44ae-4205f6e4affc@linux.vnet.ibm.com> <147e8be3-2c33-2111-aacc-dc2bb932fa8c@linux.vnet.ibm.com> From: Laurent Dufour Date: Thu, 5 Apr 2018 18:55:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 18040516-0040-0000-0000-0000042AE250 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18040516-0041-0000-0000-0000262E1AEE Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-04-05_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804050175 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/04/2018 23:53, David Rientjes wrote: > 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. That's weird, I don't get that on my side with lockdep activated. There is a call to seqcount_init() in dup_mmap(), in mmap_region() and __vma_link_rb() and that's enough to cover all the case. That's being said, it'll be better call seqcount_init each time as soon as a vma structure is allocated. For the vm_ref_count value, as most of the time the vma is zero allocated, I don't think this is needed. I just have to check when new_vma = *old_vma is done, but this often just follow a vma allocation. > > 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. >