Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2729316ybb; Mon, 30 Mar 2020 11:42:31 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsQtWZGAQ756OdEtcSc+UEvxLr/77rNAPjMFiRCyLyBFd2+KL7tNKgGRJoyPyTXP9GN81gr X-Received: by 2002:aca:c3c1:: with SMTP id t184mr521286oif.113.1585593751006; Mon, 30 Mar 2020 11:42:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585593750; cv=none; d=google.com; s=arc-20160816; b=TXeVo0feG0tJHQdDyEufmhufDJtuQ90nloD53w75eT4IzTLrbcwIwukLpHGkTzQ8hO Af8A/ziu8j0UXBzK2BQVvnFLwzjdiQKyJpdaRxTIqIHO7XgItip5iM74AeXnvsGVlHyF kS7NgcTYEyN4PCdFZVuwqh1Xtvln+Q7B/wHDoXpZodA4ZJDSrL3yvFSlzWVb8bVzXU4q 6AEBxh8L96G98BJ1u/rz9Ba17VB+ZKDcDW4dJzDDZzXDKICWkQaT3r+SoyaSxfpDecws SroBHhzVOYP9xoAwJ3+ljxfS9k12BEMAimGX+cstw9tIprpABYDBhnHA8Oi0R+N8DMPO zrFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=82V2uiPsUi/5h2Z1obVyGYc68C87qoYt95tk3QJZeQc=; b=cw0hiXF/BY2UIXFpvRRU8synb9kYV2vB9UkA6q6/5jAol/Jk8pDvYd+LDyevwgW8iU g9Kcp7KFpOyZr6K+r5Lq5Ul//5GlhOBgABmNDqdmk59Th+9VTHXSRY+iHEeuZ1Li9qvq Jc43zsJdZWPVzh2ni77xnICaSY7DxD3x0Tzl5epRGDh+6+Z1M6xh/U1FMcu3otsk+3VH FSqWx1sh23tbUXZVc8hv9eXzjuIlekUfY6h+u4Btx7CaFkBWJDxUFJho+VOHBWX2aq8g aG2a0GkDxZX0nHSq17CtCboYkOYnByEv7/lo1R45926JnUpLExlm87kWJUQU1skXRQWL xLuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FKSiivlF; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s21si6615940otr.16.2020.03.30.11.42.18; Mon, 30 Mar 2020 11:42:30 -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=@gmail.com header.s=20161025 header.b=FKSiivlF; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727311AbgC3Sl7 (ORCPT + 99 others); Mon, 30 Mar 2020 14:41:59 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:43804 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726567AbgC3Sl7 (ORCPT ); Mon, 30 Mar 2020 14:41:59 -0400 Received: by mail-ed1-f65.google.com with SMTP id bd14so21977471edb.10 for ; Mon, 30 Mar 2020 11:41:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=82V2uiPsUi/5h2Z1obVyGYc68C87qoYt95tk3QJZeQc=; b=FKSiivlFGGLxFugSuEF2WX8g4AFNohF4Go4nX5riJP4GbsCOoKGmNMm4OlgdyqzU7s qglZ7MRKIuIAF+SVGzkGuXJhfPzZfc0am3r0uedhhkA08rS09+ltmyVSZuZQtYOWz0BE mIBlIXE8f9y06jv1ClIkCFe/r/xKMJ4z5XrdDzLVsHgDciPhu8UxFJxoB8NqMAvOQ5a6 tBEzBdy+qM9TSdk7xhqhvz4ZJKTpc60TU2qyHR9CSAyqm+xgApdtzbT56CLg8Jg9Um8K YzUdgA4PhKnGaBbKTzl7raIJOo1Um6eGQskJ/er4RacA8ZPJdJePOEmlAN86CQrv9B3S APtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=82V2uiPsUi/5h2Z1obVyGYc68C87qoYt95tk3QJZeQc=; b=iJN4k2uUbvmVWIGEJk6482sGWhmhGA9oEsTd1PmSCiyTeqELc+e8fZyoXQzccD0GEz SQ8rSdCzfklu0LhrUWXQP5h5eeL+zlB6/166B10CvzihyKspEs1RN4LkHdtrQ0kD/ELr xNGjmgRDqV9Ap4c6BKuTgUCqZUFVSvrlfa/PP740sVcG2Z4nP0sK4CSWDSNS751VOoc1 8X+wWX6UICtjEpFaTChEaLEE6HD0nKaUqk0DbZq7S167roF7/ARQgYtb4DtXxR2fhieM 6qzJ428yDone9LN8GLkABxIgc/rjvhESDu2iUTCcuwAawhpAzTQaLTzG975zeb/wZ2Nv /kRw== X-Gm-Message-State: ANhLgQ1zB3cZ8Q9jDattz7Entidg8v3J2zz+750LXQXeNu58L7MvD5Cg fhv+MK6wp/o5VaI/Dzl1wi+dG202/7ygr1lw3n8= X-Received: by 2002:aa7:d384:: with SMTP id x4mr6375157edq.256.1585593717445; Mon, 30 Mar 2020 11:41:57 -0700 (PDT) MIME-Version: 1.0 References: <20200327170601.18563-1-kirill.shutemov@linux.intel.com> <20200327170601.18563-6-kirill.shutemov@linux.intel.com> <20200328003920.xvkt3hp65uccsq7b@box> <20200328123336.givyrh5hsscg5cpx@box> In-Reply-To: <20200328123336.givyrh5hsscg5cpx@box> From: Yang Shi Date: Mon, 30 Mar 2020 11:41:44 -0700 Message-ID: Subject: Re: [PATCH 5/7] khugepaged: Allow to collapse PTE-mapped compound pages To: "Kirill A. Shutemov" Cc: Zi Yan , Andrew Morton , Andrea Arcangeli , Linux MM , Linux Kernel Mailing List , "Kirill A. Shutemov" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Mar 28, 2020 at 5:33 AM Kirill A. Shutemov wrote: > > 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'm wondering if we shall skip putting the page back to LRU. Since the page is about to be freed soon, so as I mentioned in the other patch it sounds not very productive to put it back to LRU again. > > 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 >