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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0EA9D1715C for ; Tue, 22 Oct 2024 03:47:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DE9FE6B008C; Mon, 21 Oct 2024 23:47:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D9B336B0092; Mon, 21 Oct 2024 23:47:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C895C6B0093; Mon, 21 Oct 2024 23:47:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A82E16B008C for ; Mon, 21 Oct 2024 23:47:25 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 342E41C6924 for ; Tue, 22 Oct 2024 03:47:07 +0000 (UTC) X-FDA: 82699852956.18.26C5D7D Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf07.hostedemail.com (Postfix) with ESMTP id 4EEB640006 for ; Tue, 22 Oct 2024 03:47:01 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=hPYEsg+D; spf=none (imf07.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729568767; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Q0X7i+0aRUlONZNiN6Q45nEvrk+L/+N1T0pRsBP18nM=; b=gAy1F5NY2gYt32bLOSxMDZMU1nZ2yuVm5Y/WZPDt3FUgTjUdNi6/VcSHstBpT8W/FOWsqF dAzpcnbr/7Lq85liPo4bXzUo24BuiDWFedraJGDwhQcekUsTbwlb/OE7pGckxEBUvnFxEd 4RFT1kmdBXUmJdFaazM0tNH0W1ujvX4= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=hPYEsg+D; spf=none (imf07.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729568767; a=rsa-sha256; cv=none; b=ftzJ5u8SFQPID4b0kEd8Bc59nK0wbJ/nkR9SUq0fv4LZ9ddUCvsZCPvH5IIcz24OV0+7cl KVd27+KXH/QD+irDUl7TojjMMA08VZwKRIQ/nKhsJtPw+FQ8kJiiyWE4YO9bIJDoyvG+sB Onsq0ingHgy2qX5wklDq72iRrvNhVBA= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Q0X7i+0aRUlONZNiN6Q45nEvrk+L/+N1T0pRsBP18nM=; b=hPYEsg+DTgh4nxkHsiCAcw+RiA rUQ6PzIR0AbGubFV0pQu/2hC+Ia96xI9s85ji/7z7if9D8GtjXKipRWyqW6NbARaBin0vpSquMqNA P9dAN93UxAMdQkSTkJyhWG/qfrDHz3hq6QGcspkgkQqigF1+YH5dGyfjDNmQGd9jasGEVPFUN4xDx lbd7f+YRGOxJC6rMpYeQusmScbf947q6fVboY8PG9bl96Ro9szupHXq7iRsbI3bfFzK31hUD5xzko iUVdsiJ0GOOjxVnVKHxhbEYYrXJKW0NItcaf45BZsvt6+Gu9Wo1N2uoPm97bV50WiiIR+lnwAkk/t 9WRnJXkg==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1t35rb-0000000H4mW-2IUg; Tue, 22 Oct 2024 03:47:19 +0000 Date: Tue, 22 Oct 2024 04:47:19 +0100 From: Matthew Wilcox To: Roman Gushchin Cc: Andrew Morton , linux-mm@kvack.org, Vlastimil Babka , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Hugh Dickins Subject: Re: [PATCH v2] mm: page_alloc: move mlocked flag clearance into free_pages_prepare() Message-ID: References: <20241021173455.2691973-1-roman.gushchin@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 4EEB640006 X-Stat-Signature: q31uzr48gjc7d7uoh3zg79jkut6bswu4 X-HE-Tag: 1729568821-962862 X-HE-Meta: U2FsdGVkX1+aQpPxaDwfkwErtARHWFNeOJWL70kR9TxAmfvePoBUNeea8iNQ0uaf3hEb8l2s9M0hDmzNJJ4SuUE1IM5GHloAPcGfRDAVqoYspVKoPdWggTajCmTsqVF/zs+ErQq+rxDX/RG2jAw2fMvmNY8MoJZfmnjbsyBrEv0cjQhhFCaJzTFDxQlLNT0Mx5kKSLHVsVn1/gqeMjBNgJx33pinHgXuK8I0KbSvyCArBpIdW+p2pNXYwDulbxHHR3p67PYOfsSxS5A44iMxPAnkMvgC+UrfUhvmEtFQpLxyCA1uUhWgD38Dvk4jPqUp8F0oNR3KkEmPObq2t1Vsg/q3VQV946iqVzy5ZNA5Zx6EE0k5+2hAHfkDMCtNonw6UjDMKmTUMEX714wfP8nvbLob11S5fl/1dThwnT4CFcEBoS8LI0pFd24tObQm8PXFiop5LpAD9OSHZR9NnMRZYmWQ8Asj4/bjrJZ2tyUUReSZiZTyCJyiqi+FU3T8v6Os61NGnIoJEKIu14evVv+qwBSZOa/hX0x7M1XWooF+GuUlWoRtYhjssw60skLKreHXfHG8mUfyVRfM5ppqRTxt+PxJAWD8CtXyJPMC5fnVKjYJla6W+YaYHNIc3KR33Vr69ZnA1afdLmlbBe9GDQC1Gi3ZvQr8QjPY88jxiikEqx5P8+MyewaqD4Ly2NMGle52SGiCyz5dN+9LUl19Lf0B/Y1cgjM9lPEpQqjuJjk15o9RVP4yNx8x3cUdlA+gWrW07bmrVkJlU9u0HkVsOHqQrM21dp2iDRMa/qP1KEDFacI2VEBKY+JtsabVXkg/e+QL7UjFV/SJhVrHA7uN5J/jm27ImjU9EBwXDc+nsboN2UxjBLewatkNJRhnSqpxo/z8yECyoG4Vm83CBeErao2NIwOVXIJDTBo2Qrny7Wrms8Za4CQzlwvZWjJ2hcs3znzkKgkc89nM7zXIOOSgZso Xsl+PpJO M7tmUrqTUBzGIY6YMQiH7oMH+uwLlp9dcLFkL7qfHhZYBk434oxq893DKY0uFUA41eK5gO8rtmCS8dVB+zvjdoFKRNYT9BPjeY/hiRdiSmr6hrFSitNvcyjR51aiUQ0o4f/LqummW4kMvWUwN3ot6uqdgnily+XySgI+DXZ7AgQdEO9SAtu+KaMH4uBhnZjlbB0DQ1TIs7PPJYNdL0btNp5QewZ/MDRM6HHChC0CrmzpnBg51lZ860j1j5Jh5xRBjhIdVrZM5tiAwAu2nmIaOGNYWbQ== 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: List-Subscribe: List-Unsubscribe: On Tue, Oct 22, 2024 at 02:14:39AM +0000, Roman Gushchin wrote: > On Mon, Oct 21, 2024 at 09:34:24PM +0100, Matthew Wilcox wrote: > > On Mon, Oct 21, 2024 at 05:34:55PM +0000, Roman Gushchin wrote: > > > Fix it by moving the mlocked flag clearance down to > > > free_page_prepare(). > > > > Urgh, I don't like this new reference to folio in free_pages_prepare(). > > It feels like a layering violation. I'll think about where else we > > could put this. > > I agree, but it feels like it needs quite some work to do it in a nicer way, > no way it can be backported to older kernels. As for this fix, I don't > have better ideas... Well, what is KVM doing that causes this page to get mapped to userspace? Don't tell me to look at the reproducer as it is 403 Forbidden. All I can tell is that it's freed with vfree(). Is it from kvm_dirty_ring_get_page()? That looks like the obvious thing, but I'd hate to spend a lot of time on it and then discover I was looking at the wrong thing. The reason I'm interested in looking in this direction is that we're separating pages from folios. Pages allocated through vmalloc() won't have refcounts, mapcounts, mlock bits, etc. So it's quite important to look at currently existing code and figure out how they can be modified to work in this new environment.