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 7DE93C0015E for ; Thu, 13 Jul 2023 17:34:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F02978D0003; Thu, 13 Jul 2023 13:34:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EB47B8D0002; Thu, 13 Jul 2023 13:34:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA3298D0003; Thu, 13 Jul 2023 13:34:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id CB83F8D0002 for ; Thu, 13 Jul 2023 13:34:13 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 42106140283 for ; Thu, 13 Jul 2023 17:34:13 +0000 (UTC) X-FDA: 81007287186.17.D5C8940 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf15.hostedemail.com (Postfix) with ESMTP id 5B0FEA0007 for ; Thu, 13 Jul 2023 17:34:11 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=OHpIyvXa; dmarc=none; spf=pass (imf15.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689269651; 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=7uEldnb1t08MNmip2vTnC9gPWFwn4oXzQ8E0XYFFNnU=; b=VkJecs6AsqSUll5C0ca1eoNHDp88FFWrdc8j8vZ0wNFdei41v3PqdpGZtMqO27VZ7gYYBU e6f84+YJctt/uA7MoLdRkU3z0nGhvTPL5r3UmkWWcwxXRntudjfEdZ9i68UdU6OGuxufF1 aQiprCSBzFmUA5mqZnK9nv7TjM9E3V8= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=OHpIyvXa; dmarc=none; spf=pass (imf15.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689269651; a=rsa-sha256; cv=none; b=TvdqXmiQRbYsXKzuqnrla9LO+TJgu8jSRqAcyYa0QWERCcEIsRXCqg4MeOrYCFAGyi/XzC luhdV5YCFQpVkohNYnjk4jgFhCr0i4rYevBo9fh6bsZQqvJC+HaLDIkNqQRIXdnQ4elwei Hv74CQDnpWUi4aAjKXl7bYRYvzIURbw= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 71C3561B06; Thu, 13 Jul 2023 17:34:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 390ECC433C7; Thu, 13 Jul 2023 17:34:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1689269649; bh=E5ywfrtI0Wco8qvyzBJpgMPdT7W3NwtbJglM7sjmO7U=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=OHpIyvXaC7NiiFrbSOrnSr6QNzIs34S29H5zYDRfLdgbxGk1H7VW8z7EbpMdSkFp0 N5Kor/L7l2mylFn31eRxzBdTCS+PrMrcIpB1Tm5Jw6CUiUxr7CE7a8QCBsfMQ4dSdG ytOxhDNS4uQPuGaUJ9wMfy6iCgeH5OAVeCyY7nxE= Date: Thu, 13 Jul 2023 10:34:07 -0700 From: Andrew Morton To: Mike Kravetz Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jiaqi Yan , Naoya Horiguchi , Muchun Song , Miaohe Lin , Axel Rasmussen , James Houghton , Michal Hocko , Greg Kroah-Hartman Subject: Re: [PATCH 0/2] Fix hugetlb free path race with memory errors Message-Id: <20230713103407.902e24dc90e85a9779ba885c@linux-foundation.org> In-Reply-To: <20230711220942.43706-1-mike.kravetz@oracle.com> References: <20230711220942.43706-1-mike.kravetz@oracle.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 5B0FEA0007 X-Stat-Signature: 44dn6t8prfkmg67xpu4ke8ftjkgyja4b X-HE-Tag: 1689269651-441591 X-HE-Meta: U2FsdGVkX19ITZGKdAW40jwx1o27jG9u+Y6RCEj76rcy2eqrMbjdeY0izjDNqGPRztoZxq1YNRd4ABUebplas+YQAZK2lYvGrAd3M5svWsYVljov2D6RL5WnRdC6RH/WjRX0mOFqTWSyWqhfmVC5Wnr60Ho93KMw113evKARAU22OkL+gjItjatXLhbxmsql0m7z6mjUm66D7ARwYfe51GwV1Vws98wssmEc7Iu+2ym2Du5aqNflmTIh4l3izNXQkccxEP1W8nordeoS+CjcAe1cJV7r0BBK2V9DvjuTFgle/oPq8M/t2jwTaCn9IHxK2AdVeQLtjSLJgbM4uSYPeb0Mr4ceb1gVTUvbVGOvAq52TsoXF0OLtm5MrDZ52EiJ4ln7ls/cGjiGPkyCam6qu9nNYjvzqHUGovudWQ9k9DChuQcIrbkWgPKyWl7MhCiMDGJGqWrLBMWytfYHB0Ziky/ZEhGNXu/hxlWbNVJ2mcW74gqwpuSpAhiVy9uLFlrIXkQx2qzUsBmBGnNvqU/dvSwK7GShHBv9asMqRmYBLKWAv89LascR4x+kKX67kPttA+CNJJoJScI1NCKLQyS8epVgJ5oBZ2/oOTqhI8MtJ0lwdWm+fchEdxkURq8HuSnpAyT+nA/FYgvK3KtlUvyGRL6WczlC1CVM6TAx3qrqYg15dl3L2RVfp1dQT1wPN2pPH3p9ceesKM7BWxweN4UIaXX2DqxDaNeH+j9HOWM71hxGHVRdV0ENhuO66gLud4OrJvSJmDSMFu/G4GOsfS2EmoipIdTqoGKV9yIV+dhvpxTjaO/yy+l6Z4KsRujctEJklOYA5tn933eBZ/9UFPNDDZoJFHE9zpHw5NzQ2MhcWT5ELtgKoNpvUhH1OxAlomaKGvDulZiwNWHoTe10gNjl7nCl/2Gmp9OKNRsgzx2z4R/5A/Vb+JfqVejGtyYO35W2Xv5gpo8nbPPRQFPv7uh 0Yve2rvU 1fWEAj6BPWs+2ASxK04yJNAC0zh5TggdJZgrQ9LUqYoA6yKeWqZeLs+IvwsNRUbB+NupTfuldI/SiA0dJnyYGfK5JzGGAW7RWB+yp+bdhZc7ZPincX71iKoYxEs7wvHyFx/7Quj8YvqxlwLt8hkxUrlracziuDT9gV981ojYVKjaUoVMyclVJKXdXh4MhoVM4AFX9OQBCn4aOggfpQ1ULPYzCfo8gAnXdzyoiL3ho6JcAbO0YhfkFnmT3P9AbT7myp2uopdep1+hHDCMSIYSPXpscIYO4pVsYJoeZPdf4ZnZX1ksO9sooqTPtUAEJ1AkuMSs4Rn9NcvdnNTi/KQp7tcJ5/Sc7xFk1vk40FirttUcfUxpWAT1eY8sBDA== 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: On Tue, 11 Jul 2023 15:09:40 -0700 Mike Kravetz wrote: > In the discussion of Jiaqi Yan's series "Improve hugetlbfs read on > HWPOISON hugepages" the race window was discovered. > https://lore.kernel.org/linux-mm/20230616233447.GB7371@monkey/ > > Freeing a hugetlb page back to low level memory allocators is performed > in two steps. > 1) Under hugetlb lock, remove page from hugetlb lists and clear destructor > 2) Outside lock, allocate vmemmap if necessary and call low level free > Between these two steps, the hugetlb page will appear as a normal > compound page. However, vmemmap for tail pages could be missing. > If a memory error occurs at this time, we could try to update page > flags non-existant page structs. > > A much more detailed description is in the first patch. > > The first patch addresses the race window. However, it adds a > hugetlb_lock lock/unlock cycle to every vmemmap optimized hugetlb > page free operation. This could lead to slowdowns if one is freeing > a large number of hugetlb pages. > > The second path optimizes the update_and_free_pages_bulk routine > to only take the lock once in bulk operations. > > The second patch is technically not a bug fix, but includes a Fixes > tag and Cc stable to avoid a performance regression. It can be > combined with the first, but was done separately make reviewing easier. > I feel that backporting performance improvements into -stable is not a usual thing to do. Perhaps the fact that it's a regression fix changes this, but why? Much hinges on the magnitude of the performance change. Are you able to quantify this at all?