From patchwork Wed Apr 22 00:14:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Lespinasse X-Patchwork-Id: 11502557 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 99CC314DD for ; Wed, 22 Apr 2020 00:14:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5CACA2073A for ; Wed, 22 Apr 2020 00:14:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="YU+Dpsuj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5CACA2073A 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 D574D8E000D; Tue, 21 Apr 2020 20:14:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C94488E0003; Tue, 21 Apr 2020 20:14:45 -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 B59A78E000D; Tue, 21 Apr 2020 20:14:45 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0048.hostedemail.com [216.40.44.48]) by kanga.kvack.org (Postfix) with ESMTP id 9E11C8E0003 for ; Tue, 21 Apr 2020 20:14:45 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5FA66180AD820 for ; Wed, 22 Apr 2020 00:14:45 +0000 (UTC) X-FDA: 76733570130.02.girls14_4697b5731401e X-Spam-Summary: 2,0,0,2a891a983d822679,d41d8cd98f00b204,3c4yfxgykcay2grqktmuumrk.iusrot03-ssq1giq.uxm@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:14181:14394:14659:14721:21080:21444:21451:21627:30029:30054,0,RBL:209.85.216.73:@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: girls14_4697b5731401e X-Filterd-Recvd-Size: 5608 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Wed, 22 Apr 2020 00:14:44 +0000 (UTC) Received: by mail-pj1-f73.google.com with SMTP id w4so170266pjt.2 for ; Tue, 21 Apr 2020 17:14:44 -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=2opZsbHIn/7vppLXalOzj/KzjaH4KmbCOQZ36m9L9lE=; b=YU+DpsujXi0dVqJJUn+VODEzULokQfOL0DEI1YbafX+yE0cHnEjcF9d9u7UqxpJGa7 3BcZBWBvk9crC3TVt+cufx3Fss2NCMhw6FWgs071GWBCKXJeIFvaWfxJEzUxbNvaYkJa j+6TfuSj3AiBez+mBQSM2YW7w9QCdSp+sFTVVQ8ugkK2yjdrw3Toaiel9ipwHGk+lGFu Kc4IY/Ztnjd1luBlFc1lraZ2m3sNb6BzDrJGoeXVNV/Xh8gbvbaViErJH43THqBdEFOf p2hSFugDNMm6rwwkVT+KxJC/7Q/n5/sZwMRsJ0SqpOPicpMfREqWL++llmwCv0eqVjCJ ZukQ== 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=2opZsbHIn/7vppLXalOzj/KzjaH4KmbCOQZ36m9L9lE=; b=dkr6kRN8MTE1db+jvzpXfsdNmVxQzrOt9NfRBS0pBymaWdA29fEY8DvSy6iEUkl2oB K1DpNGMO0c2hy4f6P98B1p/v4XCTAs6PJqz8iQsCgxO5R+qOT8NWrZ1uZz5Em2MJjlPD N9nWGdQdvG+0swW66uHZUJRzukzfrWv3gOba38LhosJzjpgyIW3LOFCa9S+LRTYFRGg8 5Yk+JO0TIOUUVMMIhKjFbqpGJ0Kp2D3OxaHA+XvMQUrNGOEGozIlfrwmUqIa3MBP0cZX EKag9nz9S6GVJ5wdQQ4GPcexLpPPdgSbaUVazQ6011P5+DFTdFlfeLMTmRvcHDBxIYo+ eASw== X-Gm-Message-State: AGi0PuYf8Jv4Grfw0cPydbdLNysjobX4W1SulstdkUNSxjnlORuN8x2E weAXEMqpus6cQa8QZI80s4rJzHUvnWQ= X-Google-Smtp-Source: APiQypIXTchO/qnvCAeRZjmkZ2EVbLqjiP88Fl2FWaZemSZbbMCYcFq80mBz45/FOR986aYwIIFHjDIfBSc= X-Received: by 2002:a17:90a:2709:: with SMTP id o9mr8504791pje.168.1587514483951; Tue, 21 Apr 2020 17:14:43 -0700 (PDT) Date: Tue, 21 Apr 2020 17:14:20 -0700 In-Reply-To: <20200422001422.232330-1-walken@google.com> Message-Id: <20200422001422.232330-9-walken@google.com> Mime-Version: 1.0 References: <20200422001422.232330-1-walken@google.com> X-Mailer: git-send-email 2.26.1.301.g55bc3eb7cb9-goog Subject: [PATCH v5 08/10] 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 , 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: Vlastimil Babka Reviewed-by: Laurent Dufour --- 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..9e104835a0d1 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),