Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5152726pxj; Wed, 9 Jun 2021 10:18:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCCPkpPEKfoUiKdwFAUSSZeMg3Ee70Tq8Vab/uqVnvNfuDGAEGqyEr0s3ibp5nWtYot7t/ X-Received: by 2002:a05:6402:cb4:: with SMTP id cn20mr487438edb.334.1623259092323; Wed, 09 Jun 2021 10:18:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623259092; cv=none; d=google.com; s=arc-20160816; b=WJdqzRPB2xY+zYGbDzXcbTtLkKxAJ6xDW/gnUkYUyGg5GFrFJZTM9f1wKuuokxnM97 UJScvave1VRGeyHLIsqbl7EKrpy2oN/avNzwGqBz4jLpyPcBBF8rRF6FyefBF5AP3PHu DH5HNejpNiJNHA+Xt5BfZPpUHzXcPrF1wXSBJAR1M33BnF5ehpvRSuCYroZIsVhiuFcD eCW2CRg8HoiUC32lIO0O2kUUkBrMBcHCBNZycixOCCLhycgD076mJsJ2MXdqFmaEe00M 9mr1MJKZgsM82bAVpcsJvCHs5F2VT2phjxK3E/k32pNWd3L/Ex7gORUtfsOV4+gELg8o dXRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5QAkRGFxSLqzS5cp+G+f5UsgmtkiWfavXgqFMrT3FAg=; b=d04ULnmqI533wF2C1m2NSfqqlhy9oHbNhLmwhAURVuzS03AzcOB2whBR1Fk45dIPc/ 4BPjpqly4/sqaLpiEzjtbqRmSEcs+eZrsfBVD263oaT7kMPN7t4QIKU41mZd6V4iDY7e tNtB3Vo2Uv2Mr5wXQxkUX9lhBUdr9ufnrA+1sy2X8Cyqxaxhxy4JkBCyTiDd4pwInQJf i0QwTV2wuRnvX1fRukBlNOdPfZqAu5TqBM90ulNSloz0xv39L7wn7DFllwD0sI+VweiO JvCdwmGOxaX1ODRiubB1xX41F4mikBeh3Obu8u3tvWa785lGjiUidIwhzvAIqp3ead6D 0vxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=hI4SCQbN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si264080ejc.650.2021.06.09.10.17.48; Wed, 09 Jun 2021 10:18:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=hI4SCQbN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238839AbhFIK13 (ORCPT + 99 others); Wed, 9 Jun 2021 06:27:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236353AbhFIK11 (ORCPT ); Wed, 9 Jun 2021 06:27:27 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9731C061574 for ; Wed, 9 Jun 2021 03:25:32 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id c11so30998345ljd.6 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=ghqG2ttxPkTyabEGN3cQ4CRRXbuE4IHe+bqdXXZps4dznR2rYunuC6Xks+dj2MDqZV nSUeisRtiSP8aU9zaF5/qFUqRQqrqnnKedtvAjSbmHm5tDjEWnGVe5Rt1MrTtBXKwT1w nMQNeuvRTQExs/x8Kz4pmbP8/ZiknAcCTaMEyDv8Rn1enUMQmyhsuxh8HqkhetEn9PQ7 0vP/IPl0F+tu6lhSJmYChzKWtyFj3HrpRJjy2VzA5QxMkIXdNyVNFBVoTnqACPEATJxT KU4E3c59aEvYVVcnZhCOgwCSq7nvTPX/tRoCPsUOdrUT4Hnzs7FJkWuGUAMy1BN0buQL G2yg== X-Gm-Message-State: AOAM5305wcMcrSAGkzouL7cq8xryaGT9hZQizTCAxGcPIyqxChgeNpmc kSmyC2DOn2vQGKbIKSYhpYB0sp+cPO2u4Q== 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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