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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4218FC433F5 for ; Tue, 28 Sep 2021 17:00:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1787961352 for ; Tue, 28 Sep 2021 17:00:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241942AbhI1RBo (ORCPT ); Tue, 28 Sep 2021 13:01:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:47064 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241907AbhI1RBm (ORCPT ); Tue, 28 Sep 2021 13:01:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A0DC361352 for ; Tue, 28 Sep 2021 17:00:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632848402; bh=LG73icpSNBU/h5t34vTPoYSK6Cz2xz8oCZHbpUZyobE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Mrm3kuuRt9rTs8NzBZWKzW9esRU3J2gFAarVZlpdoVicveeRdIEpnxnHjVjpc3MLd qE2lRrMsL6807RAQbe8tCWwp/k+47coKlK874eHIHxpofe3f11ZbPR4VkEkRHd6/ME RRu0NJFkri4xR39TJd2LtSpOoNJrDZzSAIeOp2LrhoUMQzcepDayORyoU04TDBScv/ 9X1kk02S95m0EotJLtdfer0+O7aN3k9CUmZ4zlKu4q/f2JMsRlQC0jzZNdcxxO7s2l 0kZkmoah/UHYPpBPI/23fqgxsy27QnWQVoToOiYvlXmepnwDAn4NvsE3yXFk+SZdQh X+muqectLw59Q== Received: by mail-lf1-f42.google.com with SMTP id y28so94583271lfb.0 for ; Tue, 28 Sep 2021 10:00:02 -0700 (PDT) X-Gm-Message-State: AOAM530uO5iCxeRbmMU5h7GPf44tPnRhJD4kXyY/BXgtBNXeYTC6GBwB IB/HzyBopZZkzUXLKbkoV9lTYFPfMGDUGdCowRE= X-Google-Smtp-Source: ABdhPJxY+7EIdyIqAHPL7HS8zvTNn2gElYimnSM6iaXJpYTEkKGO3fCLONhSZe9SIqGhVwfZnGJja/w17Fp28QsN9eU= X-Received: by 2002:a2e:7503:: with SMTP id q3mr1068082ljc.48.1632848400893; Tue, 28 Sep 2021 10:00:00 -0700 (PDT) MIME-Version: 1.0 References: <20210906121200.57905-1-rongwei.wang@linux.alibaba.com> <20210922070645.47345-2-rongwei.wang@linux.alibaba.com> <20210923194343.ca0f29e1c4d361170343a6f2@linux-foundation.org> <9e41661d-9919-d556-8c49-610dae157553@linux.alibaba.com> In-Reply-To: From: Song Liu Date: Tue, 28 Sep 2021 09:59:49 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/2] mm, thp: check page mapping when truncating page cache To: Matthew Wilcox Cc: Rongwei Wang , Andrew Morton , Linux MM , Linux Kernel Mailing List , William Kucharski , Hugh Dickins Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 28, 2021 at 5:07 AM Matthew Wilcox wrote: > > On Mon, Sep 27, 2021 at 03:24:47PM -0700, Song Liu wrote: > > OTOH, does it make sense to block writes within khugepaged, like: > > @@ -1652,6 +1653,11 @@ static void collapse_file(struct mm_struct *mm, > > /* Only allocate from the target node */ > > gfp = alloc_hugepage_khugepaged_gfpmask() | __GFP_THISNODE; > > > > + if (deny_write_access(file)) { > > + result = SCAN_BUSY_WRITE; > > + return; > > + } > > The problem is that it denies, rather than blocking. That means that the > writer gets ETXTBSY instead of waiting until khugepaged is done. > Yes, I was thinking about the same problem last night and this morning. Unfortunately, I haven't got a good solution yet. Do you have some suggestions on this? Thanks, Song