From patchwork Tue Mar 29 16:04:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 12795034 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 1C504C433F5 for ; Tue, 29 Mar 2022 16:05:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A4A9A8D0003; Tue, 29 Mar 2022 12:05:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D2738D0001; Tue, 29 Mar 2022 12:05:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84B2A8D0003; Tue, 29 Mar 2022 12:05:01 -0400 (EDT) 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 753AC8D0001 for ; Tue, 29 Mar 2022 12:05:01 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 4A2E781506 for ; Tue, 29 Mar 2022 16:05:01 +0000 (UTC) X-FDA: 79297897602.05.CA739AD Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 87D8E4001F for ; Tue, 29 Mar 2022 16:05:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648569900; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=myVn/ud/g7W9TqDN/fCCVknHoq1NPUOKCp3kWuQdaq4=; b=ZzQwYG2gMTHPt10rj3l41URBN+kS4PjLOxXPS2vzd/vf5/65+d25HWWFwFua+fRMguP7xz +5u1kbUFH4M/W97+yXLBAJH4/zOQspj1k3sRaPsygOrIe6T3szrJhpzhYW2ED6E6ZQJjRQ vuIH4rG8eCqhPBbjicY/IOlJCukxbto= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-325-pxOjCAI_PzWIeFbyjZlp3g-1; Tue, 29 Mar 2022 12:04:56 -0400 X-MC-Unique: pxOjCAI_PzWIeFbyjZlp3g-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 616821C02322; Tue, 29 Mar 2022 16:04:55 +0000 (UTC) Received: from t480s.redhat.com (unknown [10.39.194.134]) by smtp.corp.redhat.com (Postfix) with ESMTP id B9AEF401E2A; Tue, 29 Mar 2022 16:04:48 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: Andrew Morton , Hugh Dickins , Linus Torvalds , David Rientjes , Shakeel Butt , John Hubbard , Jason Gunthorpe , Mike Kravetz , Mike Rapoport , Yang Shi , "Kirill A . Shutemov" , Matthew Wilcox , Vlastimil Babka , Jann Horn , Michal Hocko , Nadav Amit , Rik van Riel , Roman Gushchin , Andrea Arcangeli , Peter Xu , Donald Dutile , Christoph Hellwig , Oleg Nesterov , Jan Kara , Liang Zhang , Pedro Gomes , Oded Gabbay , linux-mm@kvack.org, David Hildenbrand , Khalid Aziz Subject: [PATCH v3 01/16] mm/rmap: fix missing swap_free() in try_to_unmap() after arch_unmap_one() failed Date: Tue, 29 Mar 2022 18:04:25 +0200 Message-Id: <20220329160440.193848-2-david@redhat.com> In-Reply-To: <20220329160440.193848-1-david@redhat.com> References: <20220329160440.193848-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 87D8E4001F X-Stat-Signature: kyebctm1di6p3dr755ex5mod5qwxxoig X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZzQwYG2g; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf11.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com X-HE-Tag: 1648569900-280898 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: In case arch_unmap_one() fails, we already did a swap_duplicate(). let's undo that properly via swap_free(). Fixes: ca827d55ebaa ("mm, swap: Add infrastructure for saving page metadata on swap") Reviewed-by: Khalid Aziz Signed-off-by: David Hildenbrand Acked-by: Vlastimil Babka --- mm/rmap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/rmap.c b/mm/rmap.c index 5cb970d51f0a..07f59bc6ffc1 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1637,6 +1637,7 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, break; } if (arch_unmap_one(mm, vma, address, pteval) < 0) { + swap_free(entry); set_pte_at(mm, address, pvmw.pte, pteval); ret = false; page_vma_mapped_walk_done(&pvmw);