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.2 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 BFA02CA9EA0 for ; Fri, 18 Oct 2019 16:58:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 59AFC2089C for ; Fri, 18 Oct 2019 16:58:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="xrIqHLjz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 59AFC2089C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 030A08E0006; Fri, 18 Oct 2019 12:58:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F23DC8E0003; Fri, 18 Oct 2019 12:58:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E3AE88E0006; Fri, 18 Oct 2019 12:58:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0250.hostedemail.com [216.40.44.250]) by kanga.kvack.org (Postfix) with ESMTP id C229A8E0003 for ; Fri, 18 Oct 2019 12:58:49 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 685AE180DC709 for ; Fri, 18 Oct 2019 16:58:49 +0000 (UTC) X-FDA: 76057514778.11.roof53_8728ed383dd39 X-HE-Tag: roof53_8728ed383dd39 X-Filterd-Recvd-Size: 4930 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Fri, 18 Oct 2019 16:58:48 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id w3so3695237pgt.5 for ; Fri, 18 Oct 2019 09:58:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=KugndHRsdwfYfF7YNG0cCcIA+ytNiB82EhhskIQFjhM=; b=xrIqHLjzTDeKKuviVwPfyXGsHV79MdU11oTTSY5TtqSlr8T1GqoOzgCfeyiR5/ZTkJ /zgp0cB0yJ60SAjtWvF6bscx4LcvqPuX0JpN4Y20aGd6xqQul2HbIQFgPVtbFgs1JSFO GvbPbg3ISZPKujiwxdQvCttehcLvoq84oeN6A8b4imT9U2VVoLS65owqJhfPCqIVKHqb lLyNaZCnM3TEoWfgu9EpSvU4y5qlYYW2VfVsnVe0FCrhOk1OfF2xLNDqY20CjhT+vpVW rddMSKEWkNs+FhGGYoY9BxHnNCcJJ69lwtB9iOH3X6KrlIA1RwO7a1gqPjd2JhP3K3ZN Yqmw== 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:user-agent; bh=KugndHRsdwfYfF7YNG0cCcIA+ytNiB82EhhskIQFjhM=; b=OSs4i8jDphe70t9B3MP/CXRbN22KzSZ1Skz/Cf2+ta6kVdWB6ZJv1Zh9ib+OzWeu4I b9q/zVN/Mj4OaKcEScWRbERVpoxu6bzq8OuSBdSfE4L5yxJymvSHs/xKZNR6jXwhRZ4d FqXyyCc+LQnhnEj+bEabKlDyKjgc7WkgO19hPNE6pO3hgdD9BLU8bSOQko+9dpOFSV12 YLEg2FGytXo8zTZSYTqXC+KeMtP/MckocwQNkiM/OOmeoG9CPqxazcUBRqDWEbtfpZhy avt0JJE0BOl/SyJvluXM3ppBcbYjkYO55TrA4FBgqAaLlQczoSmZ3oCpkeAAA8/3pBdx xpbw== X-Gm-Message-State: APjAAAX8+SN/9a3waQjwAXeBPZIoiD7WpEhfldf17Qr1D+2MJM8IBjkC FEv7XcYifhFon+cLw6BI6gGhBg== X-Google-Smtp-Source: APXvYqwGGUHqSe/K+1crHrk5Gkm3rlrbkZZhgXAFcSTBm2IDxKaKWZSj3FpaOKq1/JKWYNm5A5HshQ== X-Received: by 2002:a63:e156:: with SMTP id h22mr11009903pgk.266.1571417927158; Fri, 18 Oct 2019 09:58:47 -0700 (PDT) Received: from localhost ([2620:10d:c090:180::ac1a]) by smtp.gmail.com with ESMTPSA id q76sm12231699pfc.86.2019.10.18.09.58.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2019 09:58:46 -0700 (PDT) Date: Fri, 18 Oct 2019 12:58:44 -0400 From: Johannes Weiner To: Song Liu Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, matthew.wilcox@oracle.com, kernel-team@fb.com, william.kucharski@oracle.com, kirill.shutemov@linux.intel.com, Hugh Dickins Subject: Re: [PATCH v2] mm,thp: recheck each page before collapsing file THP Message-ID: <20191018165844.GB179426@cmpxchg.org> References: <20191018163754.3736610-1-songliubraving@fb.com> <20191018164943.GA179426@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191018164943.GA179426@cmpxchg.org> User-Agent: Mutt/1.12.2 (2019-09-21) 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 Fri, Oct 18, 2019 at 12:49:46PM -0400, Johannes Weiner wrote: > On Fri, Oct 18, 2019 at 09:37:54AM -0700, Song Liu wrote: > > In collapse_file(), after locking the page, it is necessary to recheck > > that the page is up-to-date. Add PageUptodate() check for both shmem THP > > and file THP. > > > > Current khugepaged should not try to collapse dirty file THP, because it > > is limited to read only text. Add a PageDirty check and warning for file > > THP. This is added after page_mapping() check, because if the page is > > truncated, it might be dirty. > > > > Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS") > > Cc: Kirill A. Shutemov > > Cc: Johannes Weiner > > Cc: Hugh Dickins > > Cc: William Kucharski > > Cc: Andrew Morton > > Signed-off-by: Song Liu > > Acked-by: Johannes Weiner We should also be able to remove the unlocked tests for those two conditions, right? diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 0a1b4b484ac5..a3ef6ce86bfa 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1601,17 +1601,6 @@ static void collapse_file(struct mm_struct *mm, result = SCAN_FAIL; goto xa_unlocked; } - } else if (!PageUptodate(page)) { - xas_unlock_irq(&xas); - wait_on_page_locked(page); - if (!trylock_page(page)) { - result = SCAN_PAGE_LOCK; - goto xa_unlocked; - } - get_page(page); - } else if (PageDirty(page)) { - result = SCAN_FAIL; - goto xa_locked; } else if (trylock_page(page)) { get_page(page); xas_unlock_irq(&xas);