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 14DC5C2BD09 for ; Fri, 28 Jun 2024 02:36:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5E10B6B008C; Thu, 27 Jun 2024 22:36:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 591FB6B0095; Thu, 27 Jun 2024 22:36:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 47F2C6B0096; Thu, 27 Jun 2024 22:36:21 -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 2B4956B008C for ; Thu, 27 Jun 2024 22:36:21 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A08101212E8 for ; Fri, 28 Jun 2024 02:36:20 +0000 (UTC) X-FDA: 82278733320.07.3B51D76 Received: from out-171.mta0.migadu.com (out-171.mta0.migadu.com [91.218.175.171]) by imf11.hostedemail.com (Postfix) with ESMTP id 5728F4000C for ; Fri, 28 Jun 2024 02:36:18 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=lYAsBF6v; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf11.hostedemail.com: domain of muchun.song@linux.dev designates 91.218.175.171 as permitted sender) smtp.mailfrom=muchun.song@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719542165; a=rsa-sha256; cv=none; b=ONs2HDtq1JreMOIvK700YcmjnsZM7DnkCFPuubbTA0KgiXjqDMosVMP5Ee0JLZHgtd5RKO +SUEMIao9CcMnlCHINA+wUZIv58a0A2R1LvFSkdJenVuUxSmxqrnpxY0tF6ifzVeH8gAEh DLp6sGOFpjK1ephTDdg11nrP3h1Y9Yk= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=lYAsBF6v; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf11.hostedemail.com: domain of muchun.song@linux.dev designates 91.218.175.171 as permitted sender) smtp.mailfrom=muchun.song@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719542165; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lZ1H78Lr8pdLC8hgwNwXik7HRZRn/KcRuMAtuxdwQdk=; b=Tj0g4h3pPbXlbp4agr64XqgJvvOxu+LC4jeOzySxSks8L4IJyn7KjC6aZfIiCv2J1HlYqn 36u4XmjyFcgTr33VWM6wE8DJ191hrmpEILDzx5ifOJYkdJ6lDcc2lXM9TutKHkjPQGqiRW FxtXGVVnoi1/74MQ8L22Mr9fRCOdFoE= X-Envelope-To: yuzhao@google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1719542176; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lZ1H78Lr8pdLC8hgwNwXik7HRZRn/KcRuMAtuxdwQdk=; b=lYAsBF6v/GqCpcUGM2oxS51sOoC5pjJzP86e4RCeJzmj/KdeJViSI/OmQ2yqIDCCsYq5VG TP6Pzc8InAAaKbzofGUowMgEfhTGBjh8v0qzPdtZOi2jqMi+07ET8BNfOEuhHN21Kd1GVP Ok2urOve5UE0CYpb5Q0WYGUwr0XrIzA= X-Envelope-To: akpm@linux-foundation.org X-Envelope-To: david@redhat.com X-Envelope-To: fvdl@google.com X-Envelope-To: willy@infradead.org X-Envelope-To: peterx@redhat.com X-Envelope-To: yang@os.amperecomputing.com X-Envelope-To: linux-mm@kvack.org X-Envelope-To: linux-kernel@vger.kernel.org Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: [PATCH mm-unstable v2] mm/hugetlb_vmemmap: fix race with speculative PFN walkers X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: Date: Fri, 28 Jun 2024 10:35:16 +0800 Cc: Andrew Morton , David Hildenbrand , Frank van der Linden , "Matthew Wilcox (Oracle)" , Peter Xu , Yang Shi , Linux-MM , LKML Content-Transfer-Encoding: quoted-printable Message-Id: <38D49672-674B-43F8-AFD3-73BFD8876DCE@linux.dev> References: <20240627222705.2974207-1-yuzhao@google.com> <20240627154721.69aea29609984bd5422afc97@linux-foundation.org> To: Yu Zhao X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 5728F4000C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 9fdnjwnizwu3ymhx3noy3awecjqg1ugt X-HE-Tag: 1719542178-237446 X-HE-Meta: U2FsdGVkX1/JSJXMapUcFMrQyZrHSYlxRE8s5IuMxaPN7UyCAvGfe7AggjfX8wI58GMogfJ/CjXcQjAosv+TfZr2PTYV13DMkaWpI/zSDX3vSZKqgdBsUtFzev2eDZ0kiqnZzfQF+PgWjIzQoSutZqfT53EpGdTDBV0b1u4oRW/tpaLsZrDIjunKKOxMzOO+mrZXSSKPHa2FUKqDueYJ2cinbJfqMRwGkynewA/OCvucd4u0P0vyYt8jJPn+Yl+lClV+XKycPTLsBUbgn6fYGwDM9QtwFnx7v5HMw6T71gId90pZED94ayhXMF5fOtfrguiPQ1PQ3CRZXUGmsOqNljK6poCYUnt3OXwRD0Eyl0le9B83YZo191JQ4FPtJh2NurulLXSJMg9FtPhhBZKPCzDVq8iUCH25hamMqS0m/zmvwTpeGqYmGX4sqPQWUJ3yj6Hu0RdI8G7aSkQfv0pt1qyWg96EXoalpH0RTAjy1p6ASX6ORz6KfIi5IWkU+5uEKIPSRCcNfq/07rOb2cZkuBdGkpT7hAzzbyo9DBpfZUN2Y1hNbAsT6Wo4Ic6FY0w0ACYMkLqOtC5vgo5OQxfWCaTaqaz7Sg3JDUe/yQbBoUB9piTmHXT4dLJCVBFi/jOUlbtRVNdKpb3UOJFS8AS58La2u2VOon6WTLrp9sEoeEg0FdMHY0LG7BSAqDpU0Dleg9OV5uRvP+sBX3cnB418+uNhJOrv09kk3Ad5h2bt9QZzNWAnpHOAXkL8cPDKOp/EG+tEkTAKZvZSnrAhxusx1KTnm4VBjfdlJtMf/oZI9+PkTNSrFTDuNtfP6poxisHzTRkSgRuqO+DcDd51hUy7Q1BX+oP8iqouHM4DoXk2fWG7YZ/J/2jMm0X4FZlNP5y3L3RbNkDFOYITQN0wweCsMA3/fhzUajLSWFRw1nZjryxR6zY61O43PbgQZ00NI7mdybdJf32mxdgUE357ku/ /eaiKbge KK/6IWMU+0vYnzOdlnMaaAgXLqVEJmS0cbG+Mvd0HF0UOXFaTuwC+SO0Ynxh/xUe8p+9Oi5+UYBbIL/yihwbIzsBk6jrAzuf29TkbkRd4W0k3vJlx+JE27xeIL15TnU4IxrWauMGS0//nrYiTQ+LPzTmQ4URAIoWPBtrD/gOv35Rt8vTzJA2mCfyYcoQN/DRRnKs1ucxq7A0rU/9M2BCggwMUfcp/SG8Lrv5oaIwTIZfh6m7BgphcCpca90CgronHHAp8UqUT70ayZMc5uXPpvY8TDA== 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 Jun 28, 2024, at 07:04, Yu Zhao wrote: >=20 > On Thu, Jun 27, 2024 at 4:47=E2=80=AFPM Andrew Morton = wrote: >>=20 >> On Thu, 27 Jun 2024 16:27:05 -0600 Yu Zhao wrote: >>=20 >>> While investigating HVO for THPs [1], it turns out that speculative >>> PFN walkers like compaction can race with vmemmap modifications, = e.g., >>>=20 >>> CPU 1 (vmemmap modifier) CPU 2 (speculative PFN walker) >>> ------------------------------- ------------------------------ >>> Allocates an LRU folio page1 >>> Sees page1 >>> Frees page1 >>>=20 >>> Allocates a hugeTLB folio page2 >>> (page1 being a tail of page2) >>>=20 >>> Updates vmemmap mapping page1 >>> get_page_unless_zero(page1) >>>=20 >>> Even though page1->_refcount is zero after HVO, = get_page_unless_zero() >>> can still try to modify this read-only field, resulting in a crash. >>=20 >> Ah. So we should backport this into earlier kernels, yes? >>=20 >> Are we able to identify a Fixes: for this? Looks difficult. >>=20 >> This seems quite hard to trigger. Do any particular userspace = actions >> invoke the race? >=20 > Yes, *very* hard to trigger: > 1. Most hugeTLB use cases I know of are static, i.e., reserved at boot > time, because allocating at runtime is not reliable at all. > 2. On top of that, someone has to be very unlucky to get tripped over > above, because the race window is so small -- I wasn't able to trigger > it with a stress testing that does nothing but that (with THPs > though). >=20 > So I don't think it's worth cc'ing stable, unless Muchun recommends. I agree with Yu. Thanks.