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=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 D991EC43331 for ; Sat, 28 Mar 2020 12:33:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9B0F020716 for ; Sat, 28 Mar 2020 12:33:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="tH/Wvg7x" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B0F020716 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 2CD076B0036; Sat, 28 Mar 2020 08:33:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 27D766B0037; Sat, 28 Mar 2020 08:33:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1943C6B006C; Sat, 28 Mar 2020 08:33:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0094.hostedemail.com [216.40.44.94]) by kanga.kvack.org (Postfix) with ESMTP id 0123D6B0036 for ; Sat, 28 Mar 2020 08:33:35 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 66EAB5DE7 for ; Sat, 28 Mar 2020 12:33:35 +0000 (UTC) X-FDA: 76644711990.28.birth55_769b8521aa10d X-HE-Tag: birth55_769b8521aa10d X-Filterd-Recvd-Size: 4913 Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Sat, 28 Mar 2020 12:33:34 +0000 (UTC) Received: by mail-lf1-f66.google.com with SMTP id j188so10067833lfj.11 for ; Sat, 28 Mar 2020 05:33:35 -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=KQZhDw3BcjfJrwSpFbEwWhvgR0Y2LSUS07rGTSfFYso=; b=tH/Wvg7xl9d2CAmy0krh4Fh9fI+oUD/lk+rSkSscKJrhWiZLHn2O0REaooq+ncYAvR mg58d4CH0luazTJQZlSUCLHi9Ic6NopdDlM4pGO/Mb0T/JmC1TTdjZVYTYvOxFhw/Hpd mpqb0onSPacnGHrl/ELD1TAEG2AdB1kOjVkTDErLWyZ05Eq/OUOYf4eD+PoOjCkxSUVd SWRgQ24Vo6ed3DEsxsDGd1GJtBa85F7ihUCTPiwDt82EqUgQhcWF8D2u9cPuxbdiR4ND h5Rozs68JxQ2xROcjgEt3DMZr/X0uH2L2av7btqXD5GoB/vHdjNvwZtyBroJUk6EIJ95 lmkg== 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=KQZhDw3BcjfJrwSpFbEwWhvgR0Y2LSUS07rGTSfFYso=; b=rOGPQRPoijS5ssCI9AoD+6RBdX0AzZcLp3OdarEWF5puzV7X1RtItMZs6OaPXQ1jR2 C3hEq8MktfL4qmbIAncPitiYsd2GzDmRZW8SOaVSqNka+rZ1yG7dco7u86YPeIBpTbff u9R+9jjVFNvWmYpV2QdVcL8ZrKMhS57ABwGCc7ufs4GpYYzPZmENsprY4NMmih71XvYx xyuFk0X0qiJGzt9Kadt31utQ/LsucVsxOmKQ520QX2pwUjZor5R5RdD4l68RkCH4g+i+ qVEpBTrmMPOqULkQD2b1QHWZAxjiEWpmFxHx2ab/i1M5Ny9+SFJZu/njgNT1m37yPfrb /WEw== X-Gm-Message-State: AGi0PuZ9+N6AnI0KarchuaHTrO+i5p4zVtzh0+U8BmeJjOJPUc7QD0jT bMta5SnV4t6dVtFA8i3E/srhJzcQz+k= X-Google-Smtp-Source: APiQypLHNzvIacsbuhQ6IWlLoIOu+8+JHKy8rIWKCVX/sis41dB17skJXXOzuwoTIuyXNq/EubS2UA== X-Received: by 2002:a19:4843:: with SMTP id v64mr2488531lfa.171.1585398813399; Sat, 28 Mar 2020 05:33:33 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id t1sm3874634ljo.94.2020.03.28.05.33.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Mar 2020 05:33:32 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id BAAF5100D25; Sat, 28 Mar 2020 15:33:36 +0300 (+03) Date: Sat, 28 Mar 2020 15:33:36 +0300 From: "Kirill A. Shutemov" To: Zi Yan Cc: akpm@linux-foundation.org, Andrea Arcangeli , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: Re: [PATCH 5/7] khugepaged: Allow to collapse PTE-mapped compound pages Message-ID: <20200328123336.givyrh5hsscg5cpx@box> References: <20200327170601.18563-1-kirill.shutemov@linux.intel.com> <20200327170601.18563-6-kirill.shutemov@linux.intel.com> <20200328003920.xvkt3hp65uccsq7b@box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Bogosity: Ham, tests=bogofilter, spamicity=0.000037, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Mar 27, 2020 at 09:17:00PM -0400, Zi Yan wrote: > > The compound page may be locked here if the function called for the first > > time for the page and not locked after that (becouse we've unlocked it we > > saw it the first time). The same with LRU. > > > > For the first time, the compound page is locked and not on LRU, so this VM_BUG_ON passes. > For the second time and so on, the compound page is unlocked and on the LRU, > so this VM_BUG_ON still passes. > > For base page, VM_BUG_ON passes. > > Other unexpected situation (a compound page is locked and on LRU) triggers the VM_BU_ON, > but your VM_BUG_ON will not detect this situation, right? Right. I will rework this code. I've just realized it is racy: after unlock and putback on LRU the page can be locked by somebody else and this code can unlock it which completely borken. I'll pass down compound_pagelist to release_pte_pages() and handle the situation there. > >>> if (likely(writable)) { > >>> if (likely(referenced)) { > >> > >> Do we need a list here? There should be at most one compound page we will see here, right? > > > > Um? It's outside the pte loop. We get here once per PMD range. > > > > 'page' argument to trace_mm_collapse_huge_page_isolate() is misleading: > > it's just the last page handled in the loop. > > > > Throughout the pte loop, we should only see at most one compound page, right? No. mremap(2) opens a possibility for HPAGE_PMD_NR compound pages for single PMD range. -- Kirill A. Shutemov