From patchwork Tue Jul 28 13:58:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 11689227 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D5D576C1 for ; Tue, 28 Jul 2020 13:58:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 96892207E8 for ; Tue, 28 Jul 2020 13:58:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="KqeArdqy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96892207E8 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 AAABA8D0016; Tue, 28 Jul 2020 09:58:48 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A81DF6B005D; Tue, 28 Jul 2020 09:58:48 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 997F48D0016; Tue, 28 Jul 2020 09:58:48 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0197.hostedemail.com [216.40.44.197]) by kanga.kvack.org (Postfix) with ESMTP id 7B4456B005C for ; Tue, 28 Jul 2020 09:58:48 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id F3C2F1EF1 for ; Tue, 28 Jul 2020 13:58:47 +0000 (UTC) X-FDA: 77087640336.21.body41_210b3ec26f6a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id CE9F7180442C3 for ; Tue, 28 Jul 2020 13:58:47 +0000 (UTC) X-Spam-Summary: 40,2.5,0,2a4fd1d023297025,d41d8cd98f00b204,daniel.vetter@ffwll.ch,,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1431:1437:1515:1516:1518:1535:1542:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3866:3867:3870:3871:3874:4321:5007:6261:6653:6742:7903:10011:10400:10450:10455:11026:11473:11658:11914:12043:12109:12114:12296:12297:12438:12517:12519:12555:12895:13846:13894:14096:14097:14181:14394:14659:14721:19904:19999:21080:21444:21450:21451:21627:21990:30054:30055:30064,0,RBL:209.85.128.65:@ffwll.ch:.lbl8.mailshell.net-62.14.0.100 66.201.201.201;04yrfs1uy5qqthap7rmuzmbn9p8ebocs4dd7i8n5118n9b9zfzxpzhoytmk4gir.fry5ub4jr4it1jitwy1u7f5tw7pgb4hydcsrrifntrcikzu5wbyqk3hdyb7wmk8.y-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:1:0,LFtime:113,LUA_SUMMARY:none X-HE-Tag: body41_210b3ec26f6a X-Filterd-Recvd-Size: 5350 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Tue, 28 Jul 2020 13:58:47 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id k8so7985442wma.2 for ; Tue, 28 Jul 2020 06:58:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LTjUuKu28q4AP2apkOdAzx1cK7jJDnTHDeP/9uZly44=; b=KqeArdqygfldyaA4gJRiGfTgCwK4wgPCAMC7uombuUYQ1buL6zCp8yoRWk5H+Vp2qt M36J4wt9gCrJShAOCDVpPvxoVn5Osk7fRw15JUm/WE0gwcmaIwLFFiYS3d0f5MnFSxq/ iQOkoFGM5zyBIuGT0vXj0lazqprYYPD+oNhM0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LTjUuKu28q4AP2apkOdAzx1cK7jJDnTHDeP/9uZly44=; b=kxt/aaxwR9c3b+argFldmmpPXn5MdoCCMEk3HAQnOgUhJ+4CCdap0qh7lH/u4xfGJW KnBi1S8IQ2zUaWkLg7ULVIidT8MXq9GA4AbnDEzat639lluKE8TZDZV5jTHuO/toZT2B FfygrzOvuy+2neEjMIE26XLp0gaUF3yVghKJ3xsrfjUSz5KA+nP8pvNW4qc3GGVxPMAc Ng3uatBAah1TnDowt7ULTNoibjJfFNmP8onG1Wk2UBLLe2VHOBAZAGzqkgUEp2iKmSBv qMld2KMeRcRhRb3dDTGXK03Qiu3C1bTRqiLMnff9O5QXNfPhjLmSEoua38wrbQ5BkHy0 ljXA== X-Gm-Message-State: AOAM530sUXPC9aoAdzGYFlpYrJWSHWhabb5Q1fIaFEbQkzrhCs682moD DG74ATjsK/WRAg92VEVyMolcuQ== X-Google-Smtp-Source: ABdhPJzN7u/m6RCqY38cX52hSfOrqIs4C8PfjuXHcoP5UoM1XsD3zH2RZL3E9SBC/M2256p1vsiwQw== X-Received: by 2002:a7b:c403:: with SMTP id k3mr4097843wmi.35.1595944725621; Tue, 28 Jul 2020 06:58:45 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id q6sm4505414wma.22.2020.07.28.06.58.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 06:58:44 -0700 (PDT) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , Daniel Vetter , Daniel Vetter , Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, Dave Chinner , Qian Cai , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, =?utf-8?q?Thomas_?= =?utf-8?q?Hellstr=C3=B6m?= , Andrew Morton , Jason Gunthorpe , linux-mm@kvack.org, linux-rdma@vger.kernel.org, Maarten Lankhorst Subject: [PATCH] dma-resv: lockdep-prime address_space->i_mmap_rwsem for dma-resv Date: Tue, 28 Jul 2020 15:58:39 +0200 Message-Id: <20200728135839.1035515-1-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Rspamd-Queue-Id: CE9F7180442C3 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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: 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. Signed-off-by: Daniel Vetter Cc: Sumit Semwal Cc: "Christian König" Cc: linux-media@vger.kernel.org Cc: linaro-mm-sig@lists.linaro.org Cc: Dave Chinner Cc: Qian Cai Cc: linux-xfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Cc: Thomas Hellström (Intel) Cc: Andrew Morton Cc: Jason Gunthorpe Cc: linux-mm@kvack.org Cc: linux-rdma@vger.kernel.org Cc: Maarten Lankhorst Reviewed-by: Christian König Reviewed-by: Thomas Hellström --- drivers/dma-buf/dma-resv.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 0e6675ec1d11..9678162a4ac5 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -104,12 +104,14 @@ static int __init dma_resv_lockdep(void) struct mm_struct *mm = mm_alloc(); struct ww_acquire_ctx ctx; struct dma_resv obj; + struct address_space mapping; int ret; if (!mm) return -ENOMEM; dma_resv_init(&obj); + address_space_init_once(&mapping); mmap_read_lock(mm); ww_acquire_init(&ctx, &reservation_ww_class); @@ -117,6 +119,9 @@ static int __init dma_resv_lockdep(void) if (ret == -EDEADLK) dma_resv_lock_slow(&obj, &ctx); fs_reclaim_acquire(GFP_KERNEL); + /* for unmap_mapping_range on trylocked buffer objects in shrinkers */ + i_mmap_lock_write(&mapping); + i_mmap_unlock_write(&mapping); #ifdef CONFIG_MMU_NOTIFIER lock_map_acquire(&__mmu_notifier_invalidate_range_start_map); __dma_fence_might_wait();