From patchwork Wed May 20 05:29:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Lespinasse X-Patchwork-Id: 11559329 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 900DC60D for ; Wed, 20 May 2020 05:29:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5DB8D207C4 for ; Wed, 20 May 2020 05:29:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="XgZ0MYBj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5DB8D207C4 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9450F8005C; Wed, 20 May 2020 01:29:31 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 808078002C; Wed, 20 May 2020 01:29:31 -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 60A118005C; Wed, 20 May 2020 01:29:31 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0034.hostedemail.com [216.40.44.34]) by kanga.kvack.org (Postfix) with ESMTP id 3BC3A8002C for ; Wed, 20 May 2020 01:29:31 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 02CD88248068 for ; Wed, 20 May 2020 05:29:31 +0000 (UTC) X-FDA: 76835969742.23.berry29_530be84be1c12 X-Spam-Summary: 2,0,0,faa87c3a7771f47d,d41d8cd98f00b204,3ocdexgykcmgaozys1u22uzs.q20zw18b-00y9oqy.25u@flex--walken.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1437:1516:1518:1535:1542:1593:1594:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:3138:3139:3140:3141:3142:3152:3353:3740:3865:3867:3871:4250:4321:4605:5007:6119:6261:6653:6742:9969:10004:10400:11026:11473:11658:11914:12043:12114:12296:12297:12438:12555:12895:12986:14181:14394:14659:14721:21080:21444:21451:21627:30029:30054,0,RBL:209.85.219.202:@flex--walken.bounces.google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: berry29_530be84be1c12 X-Filterd-Recvd-Size: 5744 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Wed, 20 May 2020 05:29:30 +0000 (UTC) Received: by mail-yb1-f202.google.com with SMTP id y7so797985ybj.15 for ; Tue, 19 May 2020 22:29:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=baUrqRjT3RvpPQiJbNrpdqbCcCfZQeZzSpidKaRl4yM=; b=XgZ0MYBjp/QQ5RAKRllpCcwYravdKAtbrF5pMXkCUVf2NCm/jXuE1rxMjvK40nn86F DBqDKWi3pmk69dsffz+PyGCYlsCNUn8xFoDFJtM630/9YiCIvg0En7kluix7NcPVTnxc 5M8kncj7yYHBYxSf6fjrMpqIY5h3RWdgz6NHEmAH8SS+sHsXvemZvUZkC5DHGZzSX7Vz alNNdWUB7/5QfWcZghaVCMiep/3qn3af4qAXrYIb8747nRYG77iUkvCEXzUycAnqu3vv OGtEbq7oPzUP8zHBnAV62mt1zrq8ygagulTDW7PNy9va3lOGHo8KrHBiIE4WyjrXOnGN 8Rbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=baUrqRjT3RvpPQiJbNrpdqbCcCfZQeZzSpidKaRl4yM=; b=Wpcgag/ZYikfiJvYcZwcF/TAzwUdZzubkJdLEu/75pxTchXsvWR4mqId5apjwCr+WJ 8UDGNYETN5BSUH7143tFrAJt0cptBMVt06/HhwOlFVhg9oL3x4a7XG5J8wDCAg4IsVOI qv8cvbUAMo1yeSGARnnAJ5sdD7bRztuShzpDhXqC4SB2B7LllXVpSaCo5/t3q5mVejNP qq442dEbxXWC2A9elp8waNebahR1Jqb3ogjDX3HtHEc4Hm0eBh18STII+oQrrP7wdBKM FxffyXn6IEPeSXkXywqPhwLH1RAd4UqYSTzO5P6WlcbQqOL+gIMYoKYJ70h1TrBdezfY QZCA== X-Gm-Message-State: AOAM530LsaNCBKP642/HGI+1fxwBKkBXQR9jADweoQdyjRDXYaJONbrj SfVHI9UdlOjHdi1OXmn04vb+lT9CQg8= X-Google-Smtp-Source: ABdhPJwX7AKolR7rvFLD8FiK5S+rC4975CmSeuOF7aUaBCeim62UAoqyPuR4CPyNCTa4l4lVobVU5TsjgDE= X-Received: by 2002:a5b:345:: with SMTP id q5mr4540485ybp.494.1589952569960; Tue, 19 May 2020 22:29:29 -0700 (PDT) Date: Tue, 19 May 2020 22:29:04 -0700 In-Reply-To: <20200520052908.204642-1-walken@google.com> Message-Id: <20200520052908.204642-9-walken@google.com> Mime-Version: 1.0 References: <20200520052908.204642-1-walken@google.com> X-Mailer: git-send-email 2.26.2.761.g0e0b3e54be-goog Subject: [PATCH v6 08/12] mmap locking API: add MMAP_LOCK_INITIALIZER From: Michel Lespinasse To: Andrew Morton , linux-mm Cc: LKML , Peter Zijlstra , Laurent Dufour , Vlastimil Babka , Matthew Wilcox , Liam Howlett , Jerome Glisse , Davidlohr Bueso , David Rientjes , Hugh Dickins , Ying Han , Jason Gunthorpe , Daniel Jordan , John Hubbard , Michel Lespinasse 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: Define a new initializer for the mmap locking api. Initially this just evaluates to __RWSEM_INITIALIZER as the API is defined as wrappers around rwsem. Signed-off-by: Michel Lespinasse Reviewed-by: Laurent Dufour Reviewed-by: Vlastimil Babka Reviewed-by: Daniel Jordan --- arch/x86/kernel/tboot.c | 2 +- drivers/firmware/efi/efi.c | 2 +- include/linux/mmap_lock.h | 3 +++ mm/init-mm.c | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c index b89f6ac6a0c0..885058325c20 100644 --- a/arch/x86/kernel/tboot.c +++ b/arch/x86/kernel/tboot.c @@ -90,7 +90,7 @@ static struct mm_struct tboot_mm = { .pgd = swapper_pg_dir, .mm_users = ATOMIC_INIT(2), .mm_count = ATOMIC_INIT(1), - .mmap_sem = __RWSEM_INITIALIZER(init_mm.mmap_sem), + MMAP_LOCK_INITIALIZER(init_mm) .page_table_lock = __SPIN_LOCK_UNLOCKED(init_mm.page_table_lock), .mmlist = LIST_HEAD_INIT(init_mm.mmlist), }; diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 911a2bd0f6b7..916313ec8acb 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -54,7 +54,7 @@ struct mm_struct efi_mm = { .mm_rb = RB_ROOT, .mm_users = ATOMIC_INIT(2), .mm_count = ATOMIC_INIT(1), - .mmap_sem = __RWSEM_INITIALIZER(efi_mm.mmap_sem), + MMAP_LOCK_INITIALIZER(efi_mm) .page_table_lock = __SPIN_LOCK_UNLOCKED(efi_mm.page_table_lock), .mmlist = LIST_HEAD_INIT(efi_mm.mmlist), .cpu_bitmap = { [BITS_TO_LONGS(NR_CPUS)] = 0}, diff --git a/include/linux/mmap_lock.h b/include/linux/mmap_lock.h index d1826ce42f00..acac1bf5ecd2 100644 --- a/include/linux/mmap_lock.h +++ b/include/linux/mmap_lock.h @@ -1,6 +1,9 @@ #ifndef _LINUX_MMAP_LOCK_H #define _LINUX_MMAP_LOCK_H +#define MMAP_LOCK_INITIALIZER(name) \ + .mmap_sem = __RWSEM_INITIALIZER((name).mmap_sem), + static inline void mmap_init_lock(struct mm_struct *mm) { init_rwsem(&mm->mmap_sem); diff --git a/mm/init-mm.c b/mm/init-mm.c index 19603302a77f..fe9c03d8e07b 100644 --- a/mm/init-mm.c +++ b/mm/init-mm.c @@ -31,7 +31,7 @@ struct mm_struct init_mm = { .pgd = swapper_pg_dir, .mm_users = ATOMIC_INIT(2), .mm_count = ATOMIC_INIT(1), - .mmap_sem = __RWSEM_INITIALIZER(init_mm.mmap_sem), + MMAP_LOCK_INITIALIZER(init_mm) .page_table_lock = __SPIN_LOCK_UNLOCKED(init_mm.page_table_lock), .arg_lock = __SPIN_LOCK_UNLOCKED(init_mm.arg_lock), .mmlist = LIST_HEAD_INIT(init_mm.mmlist),