Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp571403ybb; Sat, 28 Mar 2020 05:34:44 -0700 (PDT) X-Google-Smtp-Source: ADFU+vth2vmROnJy+C6mytJiEm0Z2gPDloadlYMYT+i4Go1c2OkQ/ZG/SHYK90KA60FicIqxVTkm X-Received: by 2002:aca:3b82:: with SMTP id i124mr2265027oia.61.1585398884735; Sat, 28 Mar 2020 05:34:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585398884; cv=none; d=google.com; s=arc-20160816; b=eEwFps4nm46+2M67N4rR1QZ+z/da6cOcwwTUOh3Jy6muLCHvt0g8DxXZdtz+OrdZhv DVs2OIEBczaui8c648CoB/xngRIckG1Q/UnjDzJWfj+dGT4hQw+9dAwIsUMBIuhCwmEl Q+jcbd3blMwSuMzDY5AIt+7wC/fLmyL/5Evr+lsiFVmdyyd3bpbwZazfvjtBGIb/OneR 4uiJ1EwjrO/Mcn5BehHL2r8pez0XQb/h6EbdwN7PR5BDw9GZ/BxsiwPC/N0ENoFH0FMt pmlBwvpBtBP7Te6CQTeMPBmZ33Xr19KOLuYZOsgAKtL2QCrMIVK2i665TSbD54QudgDU O3qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=KQZhDw3BcjfJrwSpFbEwWhvgR0Y2LSUS07rGTSfFYso=; b=z//f9vHaLw/ZGG/BY6iWA6E8rhvnQy1v28HRL4oXfqqz0nTD4pJ5vi0MJl302aYXU2 yObSoVkfwIjmik8cgzp0k7brNJ/3dXMkXdatOvywX73STF2QGDLSaaMKOjqAd2vZWPSz QXicW/bOPHj0VUfn4/KRCDe7vI4eAK3zMNuu8Vc4la9lPZXkyF5UqJP0Pzh4Lplh7bLL ygoe0tUnS7Bixoyo5gcNz1oaW2YYa1YQat43MRtvdi93GTjxUDaYkmoPl4L6fc5OTSkT slm0rTbwX3pQNU7kAmCMLYtV8M0WMtjUDPzDq8Nv1st2l0XSW5pbZ6DKrwPvk0vWFVnL 5InQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b="tH/Wvg7x"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r21si3896665oth.185.2020.03.28.05.34.25; Sat, 28 Mar 2020 05:34:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b="tH/Wvg7x"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726307AbgC1Mdh (ORCPT + 99 others); Sat, 28 Mar 2020 08:33:37 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:37107 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726273AbgC1Mdg (ORCPT ); Sat, 28 Mar 2020 08:33:36 -0400 Received: by mail-lf1-f65.google.com with SMTP id j11so10079874lfg.4 for ; Sat, 28 Mar 2020 05:33:34 -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=LkVfSMh6ycc2zahifJ8beJFw13u35/knDq123/XkeKKKzukRMnxsj6uPvpW3GzKdqd B7Ki07I468BndsgEbCJXNKBYrw6UPT5+KtbEmZG4Z9voX0Z4fITUhtS70wLXUcoflPQN /CQoStxzAcB3RGJLJM/o5+EBXaDt+TCioXy6FPKWOAtyhPlfEgunDIpx6axZ0VCDUvHA 2FtNP0WAekGA6PWkUySn7+kDePZDrKUg/E0m/WKUzz/Bl+k/7kUesfBVou4U90zDqAd9 D3Isqcg6NvNw8jSpMKR8HCu6DUreOEmHKMrDINPxLfeZDt6qpaku3RzeRUKW9U9SONID aZ1A== X-Gm-Message-State: AGi0PuYSQ0C5c4vHlVpdMujKRKcTa/rcLZY4UsD7F7Ay/eI2z9yqcEa+ 40NwMRp0ckxjCfSxZSbD8LUNFg== 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: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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