Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2719189ybk; Mon, 18 May 2020 06:25:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCtVD8S5K229X8BFhFS4fW/udb+LPzwwFTVnbCOvofn6qVYKnlDpCL8QXy49nX1rzySHFP X-Received: by 2002:a17:906:2799:: with SMTP id j25mr14041336ejc.369.1589808330820; Mon, 18 May 2020 06:25:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589808330; cv=none; d=google.com; s=arc-20160816; b=EikoNT9fH3f7ZxCLcta+UUY/cWHqxgSgPbNiSewl1RHbgybSZf8fjOV6uFurU7FWvy PCf8sD8sGwmGavDrRgtENgm3S64lRtMRyfRFaTJeVdLrPYl6+ktT53jdpub/9V6C8r5M I6z29NfQBUy9LbnJZ3kuixNxYuU77aqmkLsY3NGgNSfFKmGfxcn7cUYdrSvMOC58VS1Z kUFnNWnnpPOp01qguqW0EOhb/2/YTPQgcsGXmQe7drX4XAouILi3PTCKXXjZ6z6Kubw+ nC6z8R16pFEYTVg4Z2zLmqnKAAPTgU4e3h457OG9vhQBt23lNyptATuCxWBdaGTpRS/b dnSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=95dearQMP2mbMj0dDkYFKV/zWbtDSdvfx/Af7CbXIuM=; b=vvHV0CMKatH7aAK3QE8T1nDF0leLAS4J3M2NiIGLl5a7fFrqTC3GUXnMKb32M1KV+f ClOZzC/CIWOBGU0FNvtxtXKzbglJf7wij5UKpThSebgUOtRRJTd7ZNB4wVjPrzBFkGri UoU0Lu1hzVUUy3VHUo0PGRYpuZE3TQmhKFOtqNJ06bBxSEse0zgNrLgmkR/mYKbFytTj FXdwRrTZY+uT+NDRgi5NInEU7idBwCAoudFe1POS7QxCkxUFAw+PM/34AdBPNXKPIYzx 94tpfhULn2EmqEe4mPQZBcE2QN5/JLofUY1H5h+B3NCIIsuB7dxmN7NQ967qg5ZykbkY 3l2g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m4si6718458eje.107.2020.05.18.06.25.07; Mon, 18 May 2020 06:25:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727811AbgERNTb (ORCPT + 99 others); Mon, 18 May 2020 09:19:31 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:38270 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726855AbgERNTa (ORCPT ); Mon, 18 May 2020 09:19:30 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04ID413x088391; Mon, 18 May 2020 09:18:36 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 312agck66k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 May 2020 09:18:36 -0400 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 04ID4H8R090068; Mon, 18 May 2020 09:18:35 -0400 Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 312agck65j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 May 2020 09:18:35 -0400 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 04IDFda7012514; Mon, 18 May 2020 13:18:33 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma03fra.de.ibm.com with ESMTP id 3127t5hpc7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 May 2020 13:18:32 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 04IDIUh163635458 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 May 2020 13:18:30 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AC93642042; Mon, 18 May 2020 13:18:30 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BB9FB4203F; Mon, 18 May 2020 13:18:29 +0000 (GMT) Received: from pomme.local (unknown [9.145.67.24]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 18 May 2020 13:18:29 +0000 (GMT) Subject: Re: [PATCH v5 01/10] mmap locking API: initial implementation as rwsem wrappers To: Michel Lespinasse , Andrew Morton , linux-mm Cc: LKML , Peter Zijlstra , Vlastimil Babka , Matthew Wilcox , Liam Howlett , Jerome Glisse , Davidlohr Bueso , David Rientjes , Hugh Dickins , Ying Han , Jason Gunthorpe , Daniel Jordan , Davidlohr Bueso References: <20200422001422.232330-1-walken@google.com> <20200422001422.232330-2-walken@google.com> From: Laurent Dufour Message-ID: Date: Mon, 18 May 2020 15:18:29 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200422001422.232330-2-walken@google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.676 definitions=2020-05-18_05:2020-05-15,2020-05-18 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 phishscore=0 malwarescore=0 impostorscore=0 mlxlogscore=999 clxscore=1011 bulkscore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 cotscore=-2147483648 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005180114 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 22/04/2020 à 02:14, Michel Lespinasse a écrit : > This change wraps the existing mmap_sem related rwsem calls into a new > mmap locking API. There are two justifications for the new API: > > - At first, it provides an easy hooking point to instrument mmap_sem > locking latencies independently of any other rwsems. > > - In the future, it may be a starting point for replacing the rwsem > implementation with a different one, such as range locks. > > Signed-off-by: Michel Lespinasse > Reviewed-by: Daniel Jordan > Reviewed-by: Davidlohr Bueso Reviewed-by: Laurent Dufour > --- > include/linux/mm.h | 1 + > include/linux/mmap_lock.h | 54 +++++++++++++++++++++++++++++++++++++++ > 2 files changed, 55 insertions(+) > create mode 100644 include/linux/mmap_lock.h > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 5a323422d783..051ec782bdbb 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -15,6 +15,7 @@ > #include > #include > #include > +#include > #include > #include > #include > diff --git a/include/linux/mmap_lock.h b/include/linux/mmap_lock.h > new file mode 100644 > index 000000000000..97ac53b66052 > --- /dev/null > +++ b/include/linux/mmap_lock.h > @@ -0,0 +1,54 @@ > +#ifndef _LINUX_MMAP_LOCK_H > +#define _LINUX_MMAP_LOCK_H > + > +static inline void mmap_init_lock(struct mm_struct *mm) > +{ > + init_rwsem(&mm->mmap_sem); > +} > + > +static inline void mmap_write_lock(struct mm_struct *mm) > +{ > + down_write(&mm->mmap_sem); > +} > + > +static inline int mmap_write_lock_killable(struct mm_struct *mm) > +{ > + return down_write_killable(&mm->mmap_sem); > +} > + > +static inline bool mmap_write_trylock(struct mm_struct *mm) > +{ > + return down_write_trylock(&mm->mmap_sem) != 0; > +} > + > +static inline void mmap_write_unlock(struct mm_struct *mm) > +{ > + up_write(&mm->mmap_sem); > +} > + > +static inline void mmap_write_downgrade(struct mm_struct *mm) > +{ > + downgrade_write(&mm->mmap_sem); > +} > + > +static inline void mmap_read_lock(struct mm_struct *mm) > +{ > + down_read(&mm->mmap_sem); > +} > + > +static inline int mmap_read_lock_killable(struct mm_struct *mm) > +{ > + return down_read_killable(&mm->mmap_sem); > +} > + > +static inline bool mmap_read_trylock(struct mm_struct *mm) > +{ > + return down_read_trylock(&mm->mmap_sem) != 0; > +} > + > +static inline void mmap_read_unlock(struct mm_struct *mm) > +{ > + up_read(&mm->mmap_sem); > +} > + > +#endif /* _LINUX_MMAP_LOCK_H */ >