From patchwork Thu Mar 26 07:02:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Lespinasse X-Patchwork-Id: 11459399 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 F056C13A4 for ; Thu, 26 Mar 2020 07:03:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B425120A8B for ; Thu, 26 Mar 2020 07:03:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="aM2NoReH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B425120A8B 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 D493B6B0037; Thu, 26 Mar 2020 03:02:57 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CF87C6B006C; Thu, 26 Mar 2020 03:02:57 -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 C368B6B006E; Thu, 26 Mar 2020 03:02:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0112.hostedemail.com [216.40.44.112]) by kanga.kvack.org (Postfix) with ESMTP id ABCD16B0037 for ; Thu, 26 Mar 2020 03:02:57 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id A9C8D5851 for ; Thu, 26 Mar 2020 07:02:57 +0000 (UTC) X-FDA: 76636621194.12.plant45_19d18e457220f X-Spam-Summary: 2,0,0,28e07bb67f93c158,d41d8cd98f00b204,3ofn8xgykcdmlpaztcvddvat.rdbaxcjm-bbzkprz.dgv@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: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:14096:14097:14181:14394:14659:14721:21080:21444:21451:21627:30029:30054,0,RBL:209.85.219.201:@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: plant45_19d18e457220f X-Filterd-Recvd-Size: 5571 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Thu, 26 Mar 2020 07:02:57 +0000 (UTC) Received: by mail-yb1-f201.google.com with SMTP id w185so5231059ybe.3 for ; Thu, 26 Mar 2020 00:02:57 -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=6cPzqY4b80WWa29eiLyrEV/lfe6Ajij7bnzw5uITzXo=; b=aM2NoReHcssDrr2yxV6rHddBQXBxn2hg+/WxGz60+JG7QxK+e1+4HJS50I2BpVA6Sh iElPWI/anwEFXk7oFo8prH8pi6sprRM8LL9XqFONtzEj2E9k0pKC52dm0UXIZktap3Bv UNP5LqgME5RTiDZFZnAm2ycb+k49qK/VulCkipgEtUTocFmUPyUGwqtHxDGNeY3yCn2g 64yC9ywQQ0uyd42AzqyuGkz44+7OXwT7cDaKi2irkjb3K5WC/jifpp4RCQmurmVtd/f4 ZogRMELR+Dkb3TjEXkbp1LM/P2ZPyHD1bZzkXJ2iIFDrsJEhKvXLX9ZFuK80+nxcairp P6LA== 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=6cPzqY4b80WWa29eiLyrEV/lfe6Ajij7bnzw5uITzXo=; b=DBklYKacfdk09BTCA7a9Q1V6WI4BfsA9goZqe2pjceEwWZLxDKRapsjNRukwaGLqQ/ x3njyb6IE3HNsDd1aQYcZ44XTVmoDTuR4GnGXLyLnjfdKgqhlv2O9u4HcPeCXEkipBnb xapf2ADcQm9o6NUzc+0x5PSKR5prYnclmhJsrCvqt6pjE8REoH+stPUvoB/RaoVIJBuO 5VHFiu7rirvSIkJhnC8Rjs84Sfe/pa0lqxVbHYHz312zAeDP79Pym7rhin2GRgwtDCaD rB2Pxfor4VEBylY5LkRakmARXrZ+xydGhF9k7uaja8iv1R6JTpq4jqD1OsFrhDA3tCDI Bovg== X-Gm-Message-State: ANhLgQ3gorl54GwmnrU6CyZxCifRz9jZZ8RatgSdy85qATRwvheFnwbh AeVgUbGMEkOBSevSdQy/fytqgZ0lUGc= X-Google-Smtp-Source: ADFU+vvZtWBlaNE6VIsdzCAizDWWQriP3y9eoeonnGH8gSYoiCPARDW+INsKQMbIojvlvkHslIavVruIuwg= X-Received: by 2002:a25:a108:: with SMTP id z8mr12020490ybh.418.1585206176362; Thu, 26 Mar 2020 00:02:56 -0700 (PDT) Date: Thu, 26 Mar 2020 00:02:35 -0700 In-Reply-To: <20200326070236.235835-1-walken@google.com> Message-Id: <20200326070236.235835-8-walken@google.com> Mime-Version: 1.0 References: <20200326070236.235835-1-walken@google.com> X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH 7/8] 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 , 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 --- arch/x86/kernel/tboot.c | 2 +- drivers/firmware/efi/efi.c | 2 +- include/linux/mmap_lock.h | 2 ++ mm/init-mm.c | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c index b89f6ac6a0c0..4b79335624b1 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_sem = MMAP_LOCK_INITIALIZER(init_mm.mmap_sem), .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 21ea99f65113..5bdfe698cd7f 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -60,7 +60,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_sem = MMAP_LOCK_INITIALIZER(efi_mm.mmap_sem), .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 00d6cc02581d..7474b15bba38 100644 --- a/include/linux/mmap_lock.h +++ b/include/linux/mmap_lock.h @@ -1,6 +1,8 @@ #ifndef _LINUX_MMAP_LOCK_H #define _LINUX_MMAP_LOCK_H +#define MMAP_LOCK_INITIALIZER(name) __RWSEM_INITIALIZER(name) + 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..3c128bd6a30c 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_sem = MMAP_LOCK_INITIALIZER(init_mm.mmap_sem), .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),