From patchwork Tue Mar 8 21:34:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zach O'Keefe X-Patchwork-Id: 12774394 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CFB8C433F5 for ; Tue, 8 Mar 2022 21:34:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CEB2E8D0008; Tue, 8 Mar 2022 16:34:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C9C638D0001; Tue, 8 Mar 2022 16:34:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B3BDE8D0008; Tue, 8 Mar 2022 16:34:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id A10418D0001 for ; Tue, 8 Mar 2022 16:34:57 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 785588204F for ; Tue, 8 Mar 2022 21:34:57 +0000 (UTC) X-FDA: 79222524234.10.4A8413B Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) by imf05.hostedemail.com (Postfix) with ESMTP id 11483100007 for ; Tue, 8 Mar 2022 21:34:56 +0000 (UTC) Received: by mail-pf1-f202.google.com with SMTP id w68-20020a62dd47000000b004f6aa5e4824so303312pff.4 for ; Tue, 08 Mar 2022 13:34:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=YL7Ifg74lmqADJcFyq3Dg19FCQB6Gp8A8NRremZcd8k=; b=J/04UN8xXO6PfB2dgwV2d+cYmhx8EAJbGt2Dry3KROTmDlbNLWMvFSL/Rb+KplutcF cMQICc3NSHW+Iq0cFf6+a+X/d+zM4oVo0qV9RAipPXhx7TPxgZHtYyEGKPVzX05/S6W6 ZjYFHCWn3HhovCnEGljl8iCEJmW28ZPHrqUJaJgbBl6DfCj6tCg0pYLQS2ZHxpAfq/Ho ZTs58hQnbCHXJbdg4FvXZyewha6Gs7DIfM+UycLtr7zaQ/SQgRAaWaZsnybDUMykvGy6 I8EeNTsd4NUzKIBptivL9ZtFVO8W04h25MwkeUsS6jpOCmPVTMJVCYMOcvvNEk/f4EsE +MDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=YL7Ifg74lmqADJcFyq3Dg19FCQB6Gp8A8NRremZcd8k=; b=MR7Yo8Gla/0Vl8FnK6oSMGc3XBIDQQF954Bgw3dBCwZUtX6bG6KDRU59bWRM2jesJr C1M/sD1UF9YYmaCrNyYzbKC3wbA7Txkfn2B+qOZ+7+Tj/IaZsCRQT+nS3pUmvcXZw8OP gmfTXZh5SS1O2p/Jvw0mJya8XxsLuCUT+Z9UWakENMwxRgUrKNeuzvG+dkBDpqk5CNuX AIDxroxUh7feoIvgm/bZlsjqX7nJLoY8dRv43v2H5YIdQgIhyWU9o8scktnsG8DQnnCK +FN61H9ADRa48S1ylykk1dSXir6LqqnnLlVZxI4CzRH4qmkSz1vYu98cfI4jaF/Zak5E BC5g== X-Gm-Message-State: AOAM530zZI9wOUj1HjLGg31emgZOcCVMxirgVC0pMIpdCyKL/aq4Lrxt PEaogYCkdPdFIVAbU0IWVy9kI8X1KsLS X-Google-Smtp-Source: ABdhPJyikj6QzzefY5xo7SWXSM/OK/736d0/+m3Zo491Wj4wZVDep2Ui8XZDZnWT2k0Mw+7g80lkXRqnCVEx X-Received: from zokeefe3.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1b6]) (user=zokeefe job=sendgmr) by 2002:a17:90b:1e10:b0:1bf:6c78:54a9 with SMTP id pg16-20020a17090b1e1000b001bf6c7854a9mr927835pjb.1.1646775295506; Tue, 08 Mar 2022 13:34:55 -0800 (PST) Date: Tue, 8 Mar 2022 13:34:08 -0800 In-Reply-To: <20220308213417.1407042-1-zokeefe@google.com> Message-Id: <20220308213417.1407042-6-zokeefe@google.com> Mime-Version: 1.0 References: <20220308213417.1407042-1-zokeefe@google.com> X-Mailer: git-send-email 2.35.1.616.g0bdcbb4464-goog Subject: [RFC PATCH 05/14] mm/khugepaged: add mmap_assert_locked() checks to scan_pmd() From: "Zach O'Keefe" To: Alex Shi , David Hildenbrand , David Rientjes , Michal Hocko , Pasha Tatashin , SeongJae Park , Song Liu , Vlastimil Babka , Zi Yan , linux-mm@kvack.org Cc: Andrea Arcangeli , Andrew Morton , Arnd Bergmann , Axel Rasmussen , Chris Kennelly , Chris Zankel , Helge Deller , Hugh Dickins , Ivan Kokshaysky , "James E.J. Bottomley" , Jens Axboe , "Kirill A. Shutemov" , Matthew Wilcox , Matt Turner , Max Filippov , Miaohe Lin , Minchan Kim , Patrick Xia , Pavel Begunkov , Peter Xu , Richard Henderson , Thomas Bogendoerfer , Yang Shi , "Zach O'Keefe" X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 11483100007 X-Stat-Signature: 8rf7sjza7ch9jnqkbwixx38tawesc1nj Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="J/04UN8x"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf05.hostedemail.com: domain of 3_8snYgcKCE4F40uuvuw44w1u.s421y3AD-220Bqs0.47w@flex--zokeefe.bounces.google.com designates 209.85.210.202 as permitted sender) smtp.mailfrom=3_8snYgcKCE4F40uuvuw44w1u.s421y3AD-220Bqs0.47w@flex--zokeefe.bounces.google.com X-HE-Tag: 1646775296-594436 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: scan_pmd() requires mmap_lock held in read. Add a lockdep assertion to guard this condition, as scan_pmd() will be called from other contexts later in the series. Signed-off-by: Zach O'Keefe --- mm/khugepaged.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index b204bc1eefa7..56f2ef7146c7 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1253,6 +1253,7 @@ struct scan_pmd_result { struct page *head; }; +/* Called with mmap_lock held and does not drop it. */ static void scan_pmd(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long address, @@ -1267,6 +1268,7 @@ static void scan_pmd(struct mm_struct *mm, spinlock_t *ptl; int node = NUMA_NO_NODE; + mmap_assert_locked(mm); VM_BUG_ON(address & ~HPAGE_PMD_MASK); pmd = mm_find_pmd(mm, address);