From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-173.mta0.migadu.com (out-173.mta0.migadu.com [91.218.175.173]) (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 E04EF36215B for ; Thu, 9 Apr 2026 03:13:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775704383; cv=none; b=iSXefGkockoMh48uiUnX5CJtDPoaEIg7mmRoxzp4BgKDjO331XlHahMER1tNDNWWMEQtSYoLvLW06PqD983S114aBGqs5neYEi+M1d4FMWkMuZbWnWTVdf5mhWOCrDlJ1wgfeTHwrF3i0cwXAV9Rn4NHKOmTGOM5YwnKlzzQ2B4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775704383; c=relaxed/simple; bh=Tnm4ASEvxuAGS9O/mCz6vfaKJ9pgbfb88R+jjoNir8s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=gfOusfjZutJG8/fOhrsevopfHL8NzFCsc2qHagcS5JX+kE5y5+8Myf6mI0YJIT9WxXy0GJFWEHcY+xMOzdk10EfUUNXF3xPYH7gbeOmEraUwU0kshxpZwHHWxw/LOqQo+EGq7KzUqwGXyrC04rKG/2NetDNXMc/ZEwqQocSUC8M= 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=LigXKnCR; arc=none smtp.client-ip=91.218.175.173 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="LigXKnCR" 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=1775704379; 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=Tnm4ASEvxuAGS9O/mCz6vfaKJ9pgbfb88R+jjoNir8s=; b=LigXKnCRgarM21TOf/cb4B7tMyUYY2/wCuDYyxmsOjzw+ZgMZoWLg9MCgetZmYYJr1l+qZ BUIcIu3nKoEJBJ3CcMl78JKgUf1/++8fmWPaqRRePfhe6HCOCgbVS5SqWTq3W0UZT6bOhk V6u6K5kfDJFK3QJgELP3BWg/DQjbO/E= From: Lance Yang To: ye.liu@linux.dev Cc: akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org, liuye@kylinos.cn, ziy@nvidia.com, baolin.wang@linux.alibaba.com, Liam.Howlett@oracle.com, npache@redhat.com, ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org, lance.yang@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm/khugepaged: use ALIGN helpers for PMD alignment Date: Thu, 9 Apr 2026 11:12:42 +0800 Message-Id: <20260409031242.91778-1-lance.yang@linux.dev> In-Reply-To: <20260409014323.2385982-1-ye.liu@linux.dev> References: <20260409014323.2385982-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 Thu, Apr 09, 2026 at 09:43:22AM +0800, Ye Liu wrote: >From: Ye Liu > >PMD alignment in khugepaged is currently implemented using a mix of >rounding helpers and open-coded bitmask operations. > >Use ALIGN() and ALIGN_DOWN() consistently for PMD-sized address range >alignment, matching the preferred style for address and size handling. One more spot in madvise_collapse(): hend = min(hend, vma->vm_end & HPAGE_PMD_MASK); Maybe switch that one to ALIGN_DOWN() as well. And there is also in try_collapse_pte_mapped_thp(): unsigned long haddr = addr & HPAGE_PMD_MASK; Just a thought :) Lance