From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-189.mta0.migadu.com (out-189.mta0.migadu.com [91.218.175.189]) (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 F406D1EFFB7 for ; Wed, 6 May 2026 02:05:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.189 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778033147; cv=none; b=uxhUCNBxIYqETNf9MTpHnGcxJj8MPUTkfSZnatkMFHtap5nuXR/2mbZadGIc0lAr4N/vvb9cTNiestn+zk2g2ZV6uDpmgBoUR3+4Wc5Nc/z6Cn6NZdY58PIk80nz1Bt6/lkowGzWDgiuwr84P1kFpJvL9lZ6rTbVeIjDi8h6QWw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778033147; c=relaxed/simple; bh=ruoJOeKsa+nllr1oiSxS1lC4zkb0oArBrzVkM1zFFHs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=DdGbemJ34v/VTG1IUOMUiyHC4R50hRDAt56nqXB4763ZohkuQeHjlJMQcSORLBfydcztuZu53LJwBYUnz3TL/E6fEcdC4N0My+l4hwteVlEsEGc24nZSPWLoWoy8yL1gbPat1PcvcINt8ZxroRwVvISZ2OypcssGaNJlsiMaUys= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=eu/LWEgQ; arc=none smtp.client-ip=91.218.175.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="eu/LWEgQ" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1778033142; 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=zooTfGMwgUxut9TmF4UJ+R+H7n0OixPbclu6PSkIssg=; b=eu/LWEgQw6ybfH8JF0ngSDLBvaXrPp5zsR17NGm7LzHNtl89Hb8Lcr/0MHYl5ZFwaTB87d flzL4HqrESimXgWbHdfqfwpsDwLMyXZRWgX+7ka4N2JESxia03E6sEj6YAxEL4KSt3n/at dBJl7dIUW3E+ZJT6EfGdqa1i23sicmQ= From: Lance Yang To: ye.liu@linux.dev Cc: akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org, xhao@linux.alibaba.com, liuye@kylinos.cn, ziy@nvidia.com, baolin.wang@linux.alibaba.com, liam@infradead.org, npache@redhat.com, ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org, lance.yang@linux.dev, akpm@linux-foudation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm/khugepaged: clear MMF_VM_HUGEPAGE on mm_slot_alloc() failure Date: Wed, 6 May 2026 10:05:26 +0800 Message-Id: <20260506020526.18953-1-lance.yang@linux.dev> In-Reply-To: <20260506012130.9306-1-ye.liu@linux.dev> References: <20260506012130.9306-1-ye.liu@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On Wed, May 06, 2026 at 09:21:30AM +0800, 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") Nit: the title does not exactly match the original commit subject. It should be Fixes: 16618670276a ("mm: khugepaged: avoid pointless allocation for "struct mm_slot"") which includes quotes around "struct mm_slot". No need to resend; I think Andrew can fix it up when applying :) >Signed-off-by: Ye Liu >--- Thanks, LGTM. Reviewed-by: Lance Yang