Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3390264rwi; Fri, 21 Oct 2022 16:01:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5SlxkhxhxAV3bBQNpvmZijMZaUZnTrwTZQDJawPCpJlVInmciNTC02rCEIJeZgGhHD8LQg X-Received: by 2002:a65:6e81:0:b0:460:7b7a:af13 with SMTP id bm1-20020a656e81000000b004607b7aaf13mr17754330pgb.364.1666393305629; Fri, 21 Oct 2022 16:01:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666393305; cv=none; d=google.com; s=arc-20160816; b=BuM/2p9Dd7MJMG3zLm2GwCYq9zvNAZmp250f8CJbLMGO6g/c++61nNZLCG3TdifU18 Wbaks12jC5bzdU1zQNYBHamYOfqq9VRK8cukaPNs6RuFm9gA6LkjjfxaJ/vQhI19Xiwe ph1NbqKJLl9H4F5jSTEBPY6poKrRofRmpcPZXRdrnVIC9iwNraJBekYKdgGwLEGexuAJ wLiyPsZjrxUl+If27YFZXrDFHa9cDwL0cggMsykdPUDF4A2C7t5mSQRa98QiO+ID8aQ+ MUI6S8ykgA9GvpnkOyO2YYsVm3UUtb8vVtdLNxwiDRUhYGrGxS/fvgpuAHyG4QxTScEP SmIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=jbA5d1lgaEXO+4QZTUA12B0RXm0tJuHDtZjIwatPzE8=; b=os/I4/FY8oP9Pupyj/SPtRkrVotCnb7J7/Z+4r/ECHAQJFW0mOTaRWHw9zKbgY1/IG cAuNrfSmJ6wr78ZqcX+22tYKn/RHtokEsrVwP8fIFX+jIXS5jf/F2TmUQIFs3pLwWCQE iv0rMCTl8M0dgQaS+rSRASALz5EXsEZSng2jUYcbXbgZ4j41k0QZMIkVRC0P8KTji88G incBZeh/kCi6toIpddzXQiQTmnHY9fZTA8fag8KueqUSg+3a0mTJ7GedK8YrlZWQBiIQ 7LLyGwe9gCOGyXLdE1+IuWMnPARl4ECSlMv5S2th8BAiIuWtwiOJm/1lLmSmJWCKgs1J vIEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=WzRZvhoi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g13-20020a17090a67cd00b00212c87edbcesi872126pjm.76.2022.10.21.16.01.33; Fri, 21 Oct 2022 16:01:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=WzRZvhoi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229920AbiJUWgG (ORCPT + 99 others); Fri, 21 Oct 2022 18:36:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229476AbiJUWgE (ORCPT ); Fri, 21 Oct 2022 18:36:04 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 819F42958D9 for ; Fri, 21 Oct 2022 15:36:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=jbA5d1lgaEXO+4QZTUA12B0RXm0tJuHDtZjIwatPzE8=; b=WzRZvhoiPeuFx+Ec7xavHXmL6I QhQcgtDRrF5PBw/7kvFZCJswXRzKsLlQABCtobzCn/yxONSTGQWhBme6yr6kw/PmC0mdR9y+/nhJq 3uezeZIgUBM0YN9vxWoL/aDw14iPyvv6P700i0SMq39tIQFAh+CifAGtxu7ueMhdeCFJy0DvTXnRv l4t3VhtKugTJh307PUCr3Kg5ifEVxXz7a09DE4Y2FxUjvJsGLkZ/FYjBiFj3NUwa/s2vy76VV2MBr Kye1NNsvFu4O7yOPrmssHGWcY5A6YID2l6yYZSYP4Lz6n3LSjO5OfyiXqqFczxLe4X9lxY0VtuMYW /IXCUwyg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1om0cU-00DT4K-OP; Fri, 21 Oct 2022 22:36:03 +0000 Date: Fri, 21 Oct 2022 23:36:02 +0100 From: Matthew Wilcox To: Andrew Morton Cc: kernel test robot , Ira Weiny , "Fabio M. De Francesco" , lkp@lists.01.org, lkp@intel.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Peter Xu Subject: Re: [shmem] 7a7256d5f5: WARNING:possible_recursive_locking_detected Message-ID: References: <202210211215.9dc6efb5-yujie.liu@intel.com> <20221021133041.5811e1fb291eb6aaf122a59c@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221021133041.5811e1fb291eb6aaf122a59c@linux-foundation.org> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 21, 2022 at 01:30:41PM -0700, Andrew Morton wrote: > On Fri, 21 Oct 2022 14:09:16 +0100 Matthew Wilcox wrote: > > > On Fri, Oct 21, 2022 at 12:10:17PM +0800, kernel test robot wrote: > > > FYI, we noticed WARNING:possible_recursive_locking_detected due to commit (built with gcc-11): > > > > > > commit: 7a7256d5f512b6c17957df7f59cf5e281b3ddba3 ("shmem: convert shmem_mfill_atomic_pte() to use a folio") > > > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git master > > > > Ummm. Looks to me like this now occurs because of this part of the > > change: > > > > if (!zeropage) { /* COPY */ > > - page_kaddr = kmap_atomic(page); > > + page_kaddr = kmap_local_folio(folio, 0); > > ret = copy_from_user(page_kaddr, > > (const void __user *)src_addr, > > PAGE_SIZE); > > - kunmap_atomic(page_kaddr); > > + kunmap_local(page_kaddr); > > > > Should I be using __copy_from_user_inatomic() here? > > Caller __mcopy_atomic() is holding mmap_read_lock(dst_mm) and this > copy_from_user() calls > might_fault()->might_lock_read(current->mm->mmap_lock). > > And I guess might_lock_read() gets upset because we're holding another > mm's mmap_lock. Which sounds OK to me, unless a concurrent > mmap_write_lock() could jam things up. Well, are we sure that dst_mm and current->mm are necessarily different? If so, we could tell lockdep that. > But I cannot see why your patch would suddenly trigger this warning - > kmap_local_folio() and kmap_atomic() are basically the same thing. Except for the important call in kmap_atomic_prot() to pagefault_disable(). I mean, we could open-code that in the uffd code?