Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751873AbcCHTtT (ORCPT ); Tue, 8 Mar 2016 14:49:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34953 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751139AbcCHTro (ORCPT ); Tue, 8 Mar 2016 14:47:44 -0500 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= To: akpm@linux-foundation.org, , linux-mm@kvack.org Cc: Linus Torvalds , , Mel Gorman , "H. Peter Anvin" , Peter Zijlstra , Andrea Arcangeli , Johannes Weiner , Larry Woodman , Rik van Riel , Dave Airlie , Brendan Conoboy , Joe Donohue , Christophe Harle , Duncan Poole , Sherry Cheung , Subhash Gutti , John Hubbard , Mark Hairgrove , Lucien Dunning , Cameron Buschardt , Arvind Gopalakrishnan , Haggai Eran , Shachar Raindel , Liran Liss , Roland Dreier , Ben Sander , Greg Stoner , John Bridgman , Michael Mantor , Paul Blinzer , Leonid Shamis , Laurent Morichetti , Alexander Deucher , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= Subject: [PATCH v12 24/29] HMM: allow to get pointer to spinlock protecting a directory. Date: Tue, 8 Mar 2016 15:43:17 -0500 Message-Id: <1457469802-11850-25-git-send-email-jglisse@redhat.com> In-Reply-To: <1457469802-11850-1-git-send-email-jglisse@redhat.com> References: <1457469802-11850-1-git-send-email-jglisse@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1663 Lines: 59 Several use case for getting pointer to spinlock protecting a directory. Signed-off-by: Jérôme Glisse --- include/linux/hmm_pt.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/include/linux/hmm_pt.h b/include/linux/hmm_pt.h index f745d6c..22100a6 100644 --- a/include/linux/hmm_pt.h +++ b/include/linux/hmm_pt.h @@ -255,6 +255,16 @@ static inline void hmm_pt_directory_lock(struct hmm_pt *pt, spin_lock(&pt->lock); } +static inline spinlock_t *hmm_pt_directory_lock_ptr(struct hmm_pt *pt, + struct page *ptd, + unsigned level) +{ + if (level) + return &ptd->ptl; + else + return &pt->lock; +} + static inline void hmm_pt_directory_unlock(struct hmm_pt *pt, struct page *ptd, unsigned level) @@ -272,6 +282,13 @@ static inline void hmm_pt_directory_lock(struct hmm_pt *pt, spin_lock(&pt->lock); } +static inline spinlock_t *hmm_pt_directory_lock_ptr(struct hmm_pt *pt, + struct page *ptd, + unsigned level) +{ + return &pt->lock; +} + static inline void hmm_pt_directory_unlock(struct hmm_pt *pt, struct page *ptd, unsigned level) @@ -358,6 +375,14 @@ static inline void hmm_pt_iter_directory_lock(struct hmm_pt_iter *iter) hmm_pt_directory_lock(pt, iter->ptd[pt->llevel - 1], pt->llevel); } +static inline spinlock_t *hmm_pt_iter_directory_lock_ptr(struct hmm_pt_iter *i) +{ + struct hmm_pt *pt = i->pt; + + return hmm_pt_directory_lock_ptr(pt, i->ptd[pt->llevel - 1], + pt->llevel); +} + static inline void hmm_pt_iter_directory_unlock(struct hmm_pt_iter *iter) { struct hmm_pt *pt = iter->pt; -- 2.4.3