From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41E001F94F for ; Wed, 6 May 2026 05:17:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778044662; cv=none; b=kc5uswznBwucjFATkQDQNtpaOVkY+/zISTrezrEVPGXpjDq3vak4oGGkiF00g9nc1hxzyR5GrNeoI+ajA4H0hroG92R58DS0F1kDeDGfYc/f2X0dTuYrOu9piHOwrE6B1HWB1ncKocqLRKeqz4KymxMxhGUzfOdZf9IdKUKVTsM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778044662; c=relaxed/simple; bh=bXakD4Dr6EZRpa68PGMx46h3yBimcKhevSiGPmTCV3Q=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=rasfCITbsnmNnDgbKnqBU9PI6ZjRkBH4GA0Qoa7z3KZsseFR10eONS76vd7/RZYWoAx0SQ7G2PWFv+lv1KnsvqpAhZcaVfEgrCLPNa1lVPALtUX43x1XPl+5pYZ1UlTKZtyWSHOYMfxzsOdOBnrqpK56bLgyN9s0zDyNo0L7NEY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=gPOBWIOv; arc=none smtp.client-ip=115.124.30.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="gPOBWIOv" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1778044652; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=gffulxOArRAipIgbJlt1HnidYx/4fODZLq6S9dioK+E=; b=gPOBWIOvz1DyTwUgHIuveSW4DjWnn46rztCC6TtMg/J7ju7Y+neBF45CM8QDZUluOsS2LC4VRvpFbKndbAn45pLJftcewkfk5+ro2FVuRi3Ic0cIsnQI5UsPQ48xgZVgc0DT+DAp+0mrkp6mkj3u3q4UyJN9oUIMAA3V7CjvUb0= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037033178;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---0X2L3DDf_1778044649; Received: from 30.221.149.158(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0X2L3DDf_1778044649 cluster:ay36) by smtp.aliyun-inc.com; Wed, 06 May 2026 13:17:30 +0800 Message-ID: <8fa3ddff-b717-4804-b524-9b2c0447c60c@linux.alibaba.com> Date: Wed, 6 May 2026 13:17:29 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] mm/khugepaged: clear MMF_VM_HUGEPAGE on mm_slot_alloc() failure To: Ye Liu , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , Xin Hao Cc: Ye Liu , Zi Yan , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20260506012130.9306-1-ye.liu@linux.dev> From: Baolin Wang In-Reply-To: <20260506012130.9306-1-ye.liu@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 5/6/26 9:21 AM, Ye Liu wrote: > From: Ye Liu > > __khugepaged_enter() sets MMF_VM_HUGEPAGE before allocating the > corresponding mm_slot. If mm_slot_alloc() fails, the function > returns with the flag set but without inserting the mm into the > khugepaged tracking structures. > > This leaves the mm in an inconsistent state: it is marked as > registered (MMF_VM_HUGEPAGE set), but will never be scanned by > khugepaged. Future attempts to register the mm are skipped since > khugepaged_enter_vma() checks the flag and returns early. > > Fix this by clearing MMF_VM_HUGEPAGE when mm_slot_alloc() fails, > restoring the ability to retry registration later. > > Fixes: 16618670276a ("mm: khugepaged: avoid pointless allocation for struct mm_slot") > Signed-off-by: Ye Liu > --- Good catch. Feel free to add: Reviewed-by: Baolin Wang