From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_RED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23DD6C48BCD for ; Wed, 9 Jun 2021 10:25:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C8DB161181 for ; Wed, 9 Jun 2021 10:25:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C8DB161181 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 668D26B0036; Wed, 9 Jun 2021 06:25:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 618C56B006E; Wed, 9 Jun 2021 06:25:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E09E6B0070; Wed, 9 Jun 2021 06:25:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id 1B9166B0036 for ; Wed, 9 Jun 2021 06:25:33 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id BC160BA10 for ; Wed, 9 Jun 2021 10:25:32 +0000 (UTC) X-FDA: 78233803704.22.C7736A7 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) by imf19.hostedemail.com (Postfix) with ESMTP id E14FB9001E53 for ; Wed, 9 Jun 2021 10:25:27 +0000 (UTC) Received: by mail-lj1-f169.google.com with SMTP id bn21so30998054ljb.1 for ; Wed, 09 Jun 2021 03:25:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=5QAkRGFxSLqzS5cp+G+f5UsgmtkiWfavXgqFMrT3FAg=; b=hI4SCQbNR5mLaucodttiBAsDnvdq9Yjha4Cjz29yi30hhWLRtzIXvjm0ahVAu/o996 JLE7hNKw/rAXPrFpGG4L4ZX4TqnC81tpABRN2fGfkZJERPyByfUYJjGZoiyTPX2fY7mu eiBgVRfobCh/NO+TV3WN3+pAmGUZeZP5TkuYnNB5HqYfuo0lhsHaVKoElAFgOoScj3Z+ vbxTRlmfg4NayqIH1789vPQI3gmtbLzI9BUn6X3O+Is9qKXGfsCecjyLMLaZBeZoYV0M VLxPnLUKs5qO1Ijzx+mFzk0GVVAa6R3Sy7yJZ6blSwM9Ju9vL+S2jUcoxNNYeH5Pa0C2 Pl1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=5QAkRGFxSLqzS5cp+G+f5UsgmtkiWfavXgqFMrT3FAg=; b=V478xqaEDqrTF5rQekegFCPt3PGSw2Rl8fEVvTq18/wpfjAJFcc5JtZhoTnJPZ5LB+ hf84jIGXedaVY4CalxEt9z1qn466lOfuW44e//a2cSIIVW5Q7MFv7PWqFrQZVWZ7MrNZ zuoWeToU0V3DkWSNOv5MRLyP/9MSm5oRtmSXD5+sLf9XjgLRq8UIuWVALAPYKdW4du6y ssA0ioWoNsO22iYzk/LmKYmFTsYWZ4ed7Q1etqSlvYtYWIly1rev0zoIkilVn3NcWntI VPl8+mdrPZUXGhq3JXBHiZqUkUdV2GCMFBvpPKevCWKm8y0DE4vsrTLYE7GS9KRgnuLS VoOg== X-Gm-Message-State: AOAM533AadOqvdO7AoNFlpp7P/Aqof5DvoZuN02ZfE9/G1eW/pp8g3jZ TN0ju+Vq0mtR1Qul+NZAvP6mFA== X-Google-Smtp-Source: ABdhPJwn0lN3cnohZ4egedVX2Hw1kok4FVdZXXrSaCNAZdZlNr8yjXo+slWN28x3RPvckTQGK7L6tQ== X-Received: by 2002:a2e:3c08:: with SMTP id j8mr22256643lja.481.1623234329797; Wed, 09 Jun 2021 03:25:29 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id v15sm279009ljd.5.2021.06.09.03.25.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 03:25:29 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 88C9D10265B; Wed, 9 Jun 2021 13:25:44 +0300 (+03) Date: Wed, 9 Jun 2021 13:25:44 +0300 From: "Kirill A. Shutemov" To: Hugh Dickins Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 03/10] mm/thp: try_to_unmap() use TTU_SYNC for safe splitting (fwd) Message-ID: <20210609102544.lua6zb6j5g4gpsxx@box.shutemov.name> References: <6b2b6683-d9a7-b7d0-a3e5-425b96338d63@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6b2b6683-d9a7-b7d0-a3e5-425b96338d63@google.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: E14FB9001E53 X-Stat-Signature: riyjh6uzhp7hkubfwhgbop7fd4uxn1s1 Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=hI4SCQbN; dmarc=none; spf=none (imf19.hostedemail.com: domain of kirill@shutemov.name has no SPF policy when checking 209.85.208.169) smtp.mailfrom=kirill@shutemov.name X-HE-Tag: 1623234327-971673 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: On Tue, Jun 08, 2021 at 09:12:20PM -0700, Hugh Dickins wrote: > > > ---------- Forwarded message ---------- > Date: Tue, 8 Jun 2021 21:10:19 -0700 (PDT) > From: Hugh Dickins > To: Andrew Morton > Cc: Hugh Dickins , > Kirill A. Shutemov , > Yang Shi , Wang Yugui , > Matthew Wilcox , > Naoya Horiguchi , > Alistair Popple , Ralph Campbell , > Zi Yan , Miaohe Lin , > Minchan Kim , Jue Wang , > Peter Xu , Jan Kara , > Shakeel Butt , Oscar Salvador > Subject: [PATCH v2 03/10] mm/thp: try_to_unmap() use TTU_SYNC for safe splitting > > Stressing huge tmpfs often crashed on unmap_page()'s VM_BUG_ON_PAGE > (!unmap_success): with dump_page() showing mapcount:1, but then its > raw struct page output showing _mapcount ffffffff i.e. mapcount 0. > > And even if that particular VM_BUG_ON_PAGE(!unmap_success) is removed, > it is immediately followed by a VM_BUG_ON_PAGE(compound_mapcount(head)), > and further down an IS_ENABLED(CONFIG_DEBUG_VM) total_mapcount BUG(): > all indicative of some mapcount difficulty in development here perhaps. > But the !CONFIG_DEBUG_VM path handles the failures correctly and silently. > > I believe the problem is that once a racing unmap has cleared pte or pmd, > try_to_unmap_one() may skip taking the page table lock, and emerge from > try_to_unmap() before the racing task has reached decrementing mapcount. > > Instead of abandoning the unsafe VM_BUG_ON_PAGE(), and the ones that > follow, use PVMW_SYNC in try_to_unmap_one() in this case: adding TTU_SYNC > to the options, and passing that from unmap_page(). > > When CONFIG_DEBUG_VM, or for non-debug too? Consensus is to do the same > for both: the slight overhead added should rarely matter, except perhaps > if splitting sparsely-populated multiply-mapped shmem. Once confident > that bugs are fixed, TTU_SYNC here can be removed, and the race tolerated. > > Fixes: fec89c109f3a ("thp: rewrite freeze_page()/unfreeze_page() with generic rmap walkers") > Signed-off-by: Hugh Dickins > Cc: Acked-by: Kirill A. Shutemov -- Kirill A. Shutemov