Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1278276ybh; Thu, 12 Mar 2020 21:23:42 -0700 (PDT) X-Google-Smtp-Source: ADFU+vseI6RhtVsJpJKyEUxh79BzNnyUI8GNmNXSlgAFBV6aHUCKykp2srxf0XkOYwdVkSPxR9ET X-Received: by 2002:aca:450a:: with SMTP id s10mr5298180oia.25.1584073421963; Thu, 12 Mar 2020 21:23:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584073421; cv=none; d=google.com; s=arc-20160816; b=L9hK7ttugt4/Chlp5gNgUxkZUE9jwxJZGh0pdaqouM4rLpbKvMNZuql3EstgfAsZrY a7+PasWo+a/tlGYa8BR4A9JNYFlJ8BBvQEb5ztAsuY42xtdM2BfsNrbWAnvcPhUlp+kN /gyINZDEIqRHO6AVv3TJTDxwgC5h7McW9bOTDwnu3yxji3syvLX0AgH9h6fdie7dLH4V kqB3U+fsNHStRR+pJKzFZkCpDwNYNgzbzN6LGvxC2RGYclaVUi3t8AbRS/ZGOAIVCCh2 IKd7JspGHrErAU4Ap0JiXuZLXrMmGET2oIqWGIhoPWrWiWWnrC+gfuSWswRY2HSoStPe 1EuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=olUQnOtxqUHQTHVWU+Py6tKfskOSahAGyMtt/l31rlY=; b=k0Fm4UQ94WD3H3gOO7n6VuEh95+S3JZ4roPRQaJKYFBSjYtB3xRYh8Cng91VTIls2z TAdtOP7eQLEWpE3MONUfUNkblnj6dKEvZ8JQE1bdDS4I51V7Zns1LOZq/KQNM1Rnhj4p cIU0VwlPivxwOkbu7aHb8QRy7LrjxnJz9mM/hVqGkzdaHmNae8zJ7SOhZ2qzRbijRbhT q1s+n3xNQMwCwRkoDd1CqGgbk94l+3ainkE3fGCZbxSukRcU6y3KWDNXNXR3CeHBAv3K Vngsy02OgiOZjcBs5vXpT+zQ3a80JUlOTTBnmZPRh2ors4Ls5IcDtkB/2q7aDDv+emIR XGew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hc7aR29q; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 71si4240615otm.111.2020.03.12.21.23.16; Thu, 12 Mar 2020 21:23:41 -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=@gmail.com header.s=20161025 header.b=hc7aR29q; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726331AbgCMEWq (ORCPT + 99 others); Fri, 13 Mar 2020 00:22:46 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:43821 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725535AbgCMEWq (ORCPT ); Fri, 13 Mar 2020 00:22:46 -0400 Received: by mail-lj1-f193.google.com with SMTP id r7so8990281ljp.10 for ; Thu, 12 Mar 2020 21:22:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=olUQnOtxqUHQTHVWU+Py6tKfskOSahAGyMtt/l31rlY=; b=hc7aR29qbeCsqEqD0qfar4gjSHZOqGTuq1sPxpGay1+JtZbsD/Z6Fl2Bg/AzsuzWdT GRqoPXv+gsHj+FHI0yhQAZKvztZwIBZ2FvxvdFG+K62/A3ZRocl4SiWkGPALWUg0s/7r THHyQIVJuMtCBHouXC5tIF8h1+vDnr46kEJYqUkFamOywOvNJVlsxIidOSJ2EKIbdQEe ASHRmg8UBljlrWDOgtdTxml4yRMUH+0FBONCWECTeyGPBkCP7GIbs+rPDf7aUUcZDar8 9kntmQ49CsFPlWybX0uOdDzb988brg9N8ABfBxgj8BQlhahGF/A1op8pub5WMVzsvYrc iJpA== 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; bh=olUQnOtxqUHQTHVWU+Py6tKfskOSahAGyMtt/l31rlY=; b=Up89DqaQPK89QFhgbBlDb98OOax5ho5flzibjUa2zDCuHNsrZPGpSZ15clzYcjm6Es PHdBk0/O0cLbK6XJy2JShWxIh8xBJ19yZTCy0+gCWqBUpG2bSIupAcv2d2VtKSmIgXeX 2IPtjxYgjoSLi1xEjatQ6Kyoo7CWdpxSXcxOqr+xp7SVkAkOaZ3dxYrm96RKgIxADUMn O1sg/E2mdIxl+p2ndCle2LOwaYtCAHLbuquKWJ1FdHDHaRKanYSJlww5mZH8/sClDcae IidvnM6aDr6oszPAStDEmz0KkTf9wNkT8i1mmA6MKrAC/8/nKr+LMtVpAvkxIB+ffu5m qbgQ== X-Gm-Message-State: ANhLgQ2brlUxkLEkaATnqQ7u3B/APsBMb0hn1cB6grt0Q1InnMmFRKeb 3pPzhTBIHqEIYeo46kw4gN/5g2KrRd2ZrS20giE= X-Received: by 2002:a2e:9008:: with SMTP id h8mr7005623ljg.217.1584073364517; Thu, 12 Mar 2020 21:22:44 -0700 (PDT) MIME-Version: 1.0 References: <1584065460-22205-1-git-send-email-jrdr.linux@gmail.com> <20200312195850.29693d4e55ec27ae11443c0f@linux-foundation.org> <20200312205741.e97a201037103bbf51e1df40@linux-foundation.org> In-Reply-To: <20200312205741.e97a201037103bbf51e1df40@linux-foundation.org> From: Souptick Joarder Date: Fri, 13 Mar 2020 09:52:32 +0530 Message-ID: Subject: Re: [PATCH] mm/hmm.c : Remove additional check for lockdep_assert_held() To: Andrew Morton Cc: =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Linux-MM , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 13, 2020 at 9:27 AM Andrew Morton wrote: > > On Fri, 13 Mar 2020 09:17:22 +0530 Souptick Joarder wrote: > > > On Fri, Mar 13, 2020 at 8:28 AM Andrew Morton wrote: > > > > > > On Fri, 13 Mar 2020 07:41:00 +0530 Souptick Joarder wrote: > > > > > > > walk_page_range() already has a check for lockdep_assert_held(). > > > > So additional check for lockdep_assert_held() can be removed from > > > > hmm_range_fault(). > > > > > > > > ... > > > > > > > > --- a/mm/hmm.c > > > > +++ b/mm/hmm.c > > > > @@ -681,7 +681,6 @@ long hmm_range_fault(struct hmm_range *range, unsigned int flags) > > > > struct mm_struct *mm = range->notifier->mm; > > > > int ret; > > > > > > > > - lockdep_assert_held(&mm->mmap_sem); > > > > > > > > do { > > > > /* If range is no longer valid force retry. */ > > > > > > It isn't very obvious that hmm_range_fault() is and will only be called > > > from walk_page_range() (is it?) > > > > > > > Sorry Andrew, didn't get this part ? > > * hmm_range_fault() is and will only be called > > from walk_page_range() (is it?) * > > The patch assumes that hmm_range_fault() will only ever be called via > walk_page_range(). How do we know this is the case? And that it > always will be the case? > Ahh, Sorry, I think change log creates confusion. The patch assumes that walk_page_range() is called from hmm_range_fault(). currently there are two caller for hmm_range_fault(). drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c, line 859 drivers/gpu/drm/nouveau/nouveau_svm.c, line 544 in both case, * &mm->mmap_sem * lock is taken before calling hmm_range_fault(). Now inside hmm_range_fault() there is a check for lockdep_assert_held(&mm->mmap_sem) and again inside loop walk_page_range() is called which cross check same lockdep_assert_held(). So the idea is to remove the first check lockdep_assert_held(&mm->mmap_sem) in hmm_range_fault().