From patchwork Sun Jul 23 22:35:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13323371 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 68D68C001DE for ; Sun, 23 Jul 2023 22:35:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA3BC6B0074; Sun, 23 Jul 2023 18:35:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A53B56B0075; Sun, 23 Jul 2023 18:35:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F40A6B0078; Sun, 23 Jul 2023 18:35:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 802AB6B0074 for ; Sun, 23 Jul 2023 18:35:16 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B4B6D807D6 for ; Sun, 23 Jul 2023 22:35:15 +0000 (UTC) X-FDA: 81044333790.02.14A70B3 Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) by imf05.hostedemail.com (Postfix) with ESMTP id E13AA100014 for ; Sun, 23 Jul 2023 22:35:13 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=3D27d8ya; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf05.hostedemail.com: domain of hughd@google.com designates 209.85.128.180 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690151713; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=IUSbSB2mCMfMFHAYxwRiQA3gIugwk2fGEbZY8GkEjTo=; b=753hGrKoJCnBvOk1IwtIGh38QCmBcYXOLrHir7LwPIHOl9x8juLXonehztMOxwujKJQA1a 9inkps0U4kzPnG+To2eaOEC0eozan0m9R05nopBGYAgkvcg3rAKsKuxM9TKfxARJeBZOy4 YYyrodaIbogKspAxVog2TKw5EPsw3sI= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=3D27d8ya; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf05.hostedemail.com: domain of hughd@google.com designates 209.85.128.180 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690151713; a=rsa-sha256; cv=none; b=FGeGXNjmYMsyCMyun2BYfgvBxwRvDv8jYiEL0tmBryD64phv631X5nm8vWJ337n8sq3tcw 6fGN2sdVQyzIA8TJZISYiZMAm6Id9dzCbOnEKLkZm4ZWpcAmU98EQHp8yLk87JSYAyOVf+ 9oXDAuWPM5t6DO0oqKHjK5wSTC6ks1A= Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-583b3939521so20315457b3.0 for ; Sun, 23 Jul 2023 15:35:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690151713; x=1690756513; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=IUSbSB2mCMfMFHAYxwRiQA3gIugwk2fGEbZY8GkEjTo=; b=3D27d8ya3vH0G/T1jCu15x5AB5T1ggT7k5ACBc7anAc8xRgePijSQXSDiSm43Rtdh1 kx0UzJnzgxBuY1qbYtXNkgP13NjfozHbR3s5RL7gEp/LqfrpbQMKGmbsjPIaxORFr1cn g3q7oTpKvwP6F6pOMrUCrCmobjOeS4eLDXeFPDDj+Tq3VFAXi+uglQvkX5ElcZp2o06/ D9us/8JBSWfFkbtl/MPsnAA2aeXKMk3gFJ1Tdu2RXf584E+VT51mNdtOUO1BMd3X4iwk Hec7/X8hj5u47rEw4cY/omhxJZJMKe3jU3Jpzpr11vI7NFWmcQMEo/DbeQo01HQvoy1p B6GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690151713; x=1690756513; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IUSbSB2mCMfMFHAYxwRiQA3gIugwk2fGEbZY8GkEjTo=; b=WdOkjB0PJE3qIFSqeir4xi7mT/I+L5otthtQph6WK9crLOFxyN60xlJ8p6MavQi10u AQQURhIE+9MYfxmH2bwB9Nf/+PzHRWqFGWFsSca4Om3Y583Ukia2S9VQi45NzkSTgB2m FrYl5mDKW4C6971pe1g4uzNy4EXHhwvXfh0oy3c2RND1H7cM+bYLS4rxaynATWudZGCQ t11A7uNobxso1SOb1TmvHo4OoG1OndDXyefn4/mmzhxSFu90CQ1RSCmdRryhxWReNKmX i6xR2HLJ6IYYOnwPW9ytlQhEasWCeBqBl23unwCDSVYujKiHm0sPlY9NEoHX0HOq3gGT QfBQ== X-Gm-Message-State: ABy/qLb4bgoalfoco38Rah8NqFifeFCd2rYhzWq3MhImZ9IYSxv0zT0f WBi5IK4sZj/6oUyEkKYG6l5usw== X-Google-Smtp-Source: APBJJlHu4gcYD0JKCreqQkRpf7N8PwoJpBQrx7bHnSSrbqs6cYtIiCQ7XOr0psELtSbwDmhcixB5CQ== X-Received: by 2002:a81:88c6:0:b0:579:ed5f:5cd3 with SMTP id y189-20020a8188c6000000b00579ed5f5cd3mr5903716ywf.23.1690151712917; Sun, 23 Jul 2023 15:35:12 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id q2-20020a0de702000000b00565271801b6sm2442804ywe.59.2023.07.23.15.35.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jul 2023 15:35:12 -0700 (PDT) Date: Sun, 23 Jul 2023 15:35:07 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Yang Shi , Mel Gorman , Peter Xu , Peter Zijlstra , Will Deacon , Yu Zhao , Alistair Popple , Ralph Campbell , Ira Weiny , Steven Price , SeongJae Park , Lorenzo Stoakes , Huang Ying , Naoya Horiguchi , Christophe Leroy , Zack Rusin , Jason Gunthorpe , Axel Rasmussen , Anshuman Khandual , Pasha Tatashin , Miaohe Lin , Minchan Kim , Christoph Hellwig , Song Liu , Thomas Hellstrom , Russell King , "David S. Miller" , Michael Ellerman , "Aneesh Kumar K.V" , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , Gerald Schaefer , Vasily Gorbik , Jann Horn , Vishal Moola , Vlastimil Babka , Zi Yan , linux-arm-kernel@lists.infradead.org, sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v3 11/13 fix] mm/khugepaged: delete khugepaged_collapse_pte_mapped_thps(): fix In-Reply-To: Message-ID: References: <7cd843a9-aa80-14f-5eb2-33427363c20@google.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: E13AA100014 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: manh3j3zqexnjyis1wzqwuqp1qpyk1a9 X-HE-Tag: 1690151713-13663 X-HE-Meta: U2FsdGVkX1+PpTHbVC1Xijlbtr3ilqP+rLV0V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rT1NBwpB40aYn8hA9zhjYhiQKllSnLrV61wPENJvju5RELb0KoOcKOSZoOoS3oezM6YyYctamLanjjiRchdm99+7ozB3eEaAXAljiCiI0hJhJYBMt/Hfb5hUQ0ru7pNbzd9BCf3sxyg+pr1SPWpKEJGA4ijZqvuVSCj3gNoFs8dVk8hJdABHRZZX37yeNGC885+x1PkhQ7vnosoSRFhcY+1hmYqda+CA2TY/6E6C3Iz2i95DVFLBni4tVeXOkbvK8+fBpCbQX8kmUEr8Z0GaKk0OihDXbTwUmFtvBxjacQ8+Y6Cy2sMCN7ZLYFYPKCxEnsXEHDgvWLu1SfEE9ynVJ3TklkTZTrvOTpBRc3hTaaG95gl3Q/yzLn+4w== 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: Though not yet detected by syzbot, this commit was making the same mistake with mmap_locked as the previous commit: fix that. Signed-off-by: Hugh Dickins --- mm/khugepaged.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 1c773db26e88..41913730db4c 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -2380,19 +2380,17 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, int *result, mmap_locked = false; *result = hpage_collapse_scan_file(mm, khugepaged_scan.address, file, pgoff, cc); + fput(file); if (*result == SCAN_PTE_MAPPED_HUGEPAGE) { mmap_read_lock(mm); - mmap_locked = true; - if (hpage_collapse_test_exit(mm)) { - fput(file); + if (hpage_collapse_test_exit(mm)) goto breakouterloop; - } *result = collapse_pte_mapped_thp(mm, khugepaged_scan.address, false); if (*result == SCAN_PMD_MAPPED) *result = SCAN_SUCCEED; + mmap_read_unlock(mm); } - fput(file); } else { *result = hpage_collapse_scan_pmd(mm, vma, khugepaged_scan.address, &mmap_locked, cc);