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 X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E854CC433E3 for ; Thu, 30 Jul 2020 13:17:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id ACA2220838 for ; Thu, 30 Jul 2020 13:17:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="Tj45p5a0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ACA2220838 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 34C146B0006; Thu, 30 Jul 2020 09:17:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2FDAD6B0007; Thu, 30 Jul 2020 09:17:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 23BEC6B0008; Thu, 30 Jul 2020 09:17:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0236.hostedemail.com [216.40.44.236]) by kanga.kvack.org (Postfix) with ESMTP id 109516B0006 for ; Thu, 30 Jul 2020 09:17:28 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 9CCEF3621 for ; Thu, 30 Jul 2020 13:17:27 +0000 (UTC) X-FDA: 77094793734.21.play10_2a140d626f7b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 56311180442C7 for ; Thu, 30 Jul 2020 13:17:27 +0000 (UTC) X-HE-Tag: play10_2a140d626f7b X-Filterd-Recvd-Size: 4940 Received: from mail-ot1-f65.google.com (mail-ot1-f65.google.com [209.85.210.65]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Thu, 30 Jul 2020 13:17:26 +0000 (UTC) Received: by mail-ot1-f65.google.com with SMTP id v21so12748514otj.9 for ; Thu, 30 Jul 2020 06:17:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=l6NNuTlAlb+T71eovQReK+men4boXEXZJmc745e1mek=; b=Tj45p5a06zkqFl6bUdtEmCxMS67sh1pLfLaP0MJK1JKsob6GFGtCQSeLESCL2s30Bo ou0Hr4WM+OKrYig/4okfOklio8NyYxv+hqW65aWlMC+/KH2ReSdB2qWfNUvAmIpCL5GB NCD+kQkkx7Q/TROpmA3URVMeplfnD5XbvU6DY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=l6NNuTlAlb+T71eovQReK+men4boXEXZJmc745e1mek=; b=d9l8jR8Weu8+RFGm7A3W7siYA763x2Q5JDCLhu7R7nAi4KN9JTquuMhIPSTEFx9DWR otTxVxw38kocJDZY+UtBuSD5PSVEQeRmhuLgZ3LrHRj/i6tSg/pmOTMoEg+ojl3eiX3d JZ+V+gJbuOPzXh5XrAArbxPmD1oz1aKX2gdZRMWolfrr6/FHx1N5blpUvGr3Uko3oqxb Wfd3/D0k/HQbYjYH0XtmxdUTYOZqiz3NYCBxJ1h6U5LdSxnZmBgIhpBpuM737pcmLm3l BCoOK0n8Twe9HURXBW5ZkQtDsyei1zraLXvX/grcuTxqyHD/66JjUw9iYO+lMsw5V3OL hG/A== X-Gm-Message-State: AOAM532/MOBpwTluNfx4a0bSQMSAguEVoJ82pQ3EVKy8B4D6JVX9t5XC R5F3p3cH8dRCkavfaCSmgpy5BOPQx9SVTsZaVOnnCw== X-Google-Smtp-Source: ABdhPJyT+P5EKFUT/rekKMDvcsT0JZ6B1aXbsvpwMmAI2gySdtJl4PHRq6e+n9dVUTuKG5DRk4IoPKAkcy7FpSExRU8= X-Received: by 2002:a9d:6052:: with SMTP id v18mr2134622otj.303.1596115045756; Thu, 30 Jul 2020 06:17:25 -0700 (PDT) MIME-Version: 1.0 References: <20200728135839.1035515-1-daniel.vetter@ffwll.ch> <38cbc4fb-3a88-47c4-2d6c-4d90f9be42e7@shipmail.org> In-Reply-To: <38cbc4fb-3a88-47c4-2d6c-4d90f9be42e7@shipmail.org> From: Daniel Vetter Date: Thu, 30 Jul 2020 15:17:14 +0200 Message-ID: Subject: Re: [PATCH] dma-resv: lockdep-prime address_space->i_mmap_rwsem for dma-resv To: =?UTF-8?Q?Thomas_Hellstr=C3=B6m_=28Intel=29?= Cc: DRI Development , Intel Graphics Development , Daniel Vetter , Sumit Semwal , =?UTF-8?Q?Christian_K=C3=B6nig?= , "open list:DMA BUFFER SHARING FRAMEWORK" , "moderated list:DMA BUFFER SHARING FRAMEWORK" , Dave Chinner , Qian Cai , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Andrew Morton , Jason Gunthorpe , Linux MM , linux-rdma , Maarten Lankhorst Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 56311180442C7 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 Thu, Jul 30, 2020 at 2:17 PM Thomas Hellstr=C3=B6m (Intel) wrote: > > > On 7/28/20 3:58 PM, Daniel Vetter wrote: > > GPU drivers need this in their shrinkers, to be able to throw out > > mmap'ed buffers. Note that we also need dma_resv_lock in shrinkers, > > but that loop is resolved by trylocking in shrinkers. > > > > So full hierarchy is now (ignore some of the other branches we already > > have primed): > > > > mmap_read_lock -> dma_resv -> shrinkers -> i_mmap_lock_write > > > > I hope that's not inconsistent with anything mm or fs does, adding > > relevant people. > > > Looks OK to me. The mapping_dirty_helpers run under the i_mmap_lock, but > don't allocate any memory AFAICT. > > Since huge page-table-entry splitting may happen under the i_mmap_lock > from unmap_mapping_range() it might be worth figuring out how new page > directory pages are allocated, though. ofc I'm not an mm expert at all, but I did try to scroll through all i_mmap_lock_write/read callers. Found the following: - kernel/events/uprobes.c in build_map_info: /* * Needs GFP_NOWAIT to avoid i_mmap_rwsem recursion through * reclaim. This is optimistic, no harm done if it fails. */ - I got lost in the hugetlb.c code and couldn't convince myself it's not allocating page directories at various levels with something else than GFP_KERNEL. So looks like the recursion is clearly there and known, but the hugepage code is too complex and flying over my head. -Daniel > > /Thomas > > > --=20 Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch