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 E69F6C433EF for ; Wed, 22 Jun 2022 00:54:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E6118E0073; Tue, 21 Jun 2022 20:54:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 26EE78E006E; Tue, 21 Jun 2022 20:54:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1102E8E0073; Tue, 21 Jun 2022 20:54:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id F16878E006E for ; Tue, 21 Jun 2022 20:54:49 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id BC44135433 for ; Wed, 22 Jun 2022 00:54:49 +0000 (UTC) X-FDA: 79604051898.11.52423AD Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf29.hostedemail.com (Postfix) with ESMTP id 423AB12009D for ; Wed, 22 Jun 2022 00:54:49 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 47DDEB81A94; Wed, 22 Jun 2022 00:54:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75AF1C3411C; Wed, 22 Jun 2022 00:54:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1655859268; bh=zLsY+cejV+MgclUFmOF+mIQDLT4L2Ve05RVVgccPDrA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=XNrLpe2+ivTPocj4W6ZZu2HHIhSZO6AnpOUGLFm51EjN735JLsBaPIJRohI7IJMBw i+U2Hkp7Pch29MsPOaiW6Lll4BwC1xAv2fL2qILdtQKqUnVzIz6ZUqDfu4RUPuaby8 3XfL5ZLlvtNlmzVCUP4YRCupF++kOQ2a07ZGN/wI= Date: Tue, 21 Jun 2022 17:54:12 -0700 From: Andrew Morton To: "Zach O'Keefe" Cc: Yang Shi , vbabka@suse.cz, kirill.shutemov@linux.intel.com, willy@infradead.org, linmiaohe@huawei.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [v5 PATCH 4/7] mm: thp: kill transparent_hugepage_active() Message-Id: <20220621175412.02d90df5f381de0cd676adf8@linux-foundation.org> In-Reply-To: References: <20220616174840.1202070-1-shy828301@gmail.com> <20220616174840.1202070-5-shy828301@gmail.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=XNrLpe2+; dmarc=none; spf=pass (imf29.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 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=1655859289; 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=u5Uj+HH05wvm3xhv1CD+2lhxm4ez9XdPGDE/oSzp09c=; b=TBf3z5uCGCFhRQVd0m/t6W/03PLUUdcldPXcxhTc34YXBO8xRgo/v7dpwrDliCNP9nZ+Rw sW5yvRXCFOnOvFLexZRIiW21LFJIywJ00wjp+vDT/FcoqGbbUWkIak62JTQ9O3n+p/WEAP 4ak8JTEFYkyIl2C7dbYXGTBhw+FkKfs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655859289; a=rsa-sha256; cv=none; b=y/QD5h32FBM0A8DHlLl3cUFyPHhHPRKIIfTzMoocEBHW9ghU1ol1jIsRhkyaKiHAN44RZC bJ+HfjmQStrmEmGuu8hV7GJ8iYm9fR1DstrW8KCiJlU2Ny2vFE7RstCRvpNepz2JmTMGU1 o6H8s4apCGiiH3MZStyHbeS16fBU9+k= X-Stat-Signature: adzujdzjeacxgq5feyc3tkoz3qjsow18 X-Rspamd-Queue-Id: 423AB12009D X-Rspam-User: Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=XNrLpe2+; dmarc=none; spf=pass (imf29.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Rspamd-Server: rspam10 X-HE-Tag: 1655859289-7004 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, 21 Jun 2022 11:58:34 -0700 "Zach O'Keefe" wrote: > > -bool transparent_hugepage_active(struct vm_area_struct *vma) > > +bool hugepage_vma_check(struct vm_area_struct *vma, > > + unsigned long vm_flags, > > + bool smaps) > > { > > - /* The addr is used to check if the vma size fits */ > > - unsigned long addr = (vma->vm_end & HPAGE_PMD_MASK) - HPAGE_PMD_SIZE; > > + if (!transhuge_vma_enabled(vma, vm_flags)) > > + return false; > > + > > During testing my work on top this patch, I found a small bug here. > > Namely, transhuge_vma_enabled() will check vma->vm_mm->flags (to see if > MMF_DISABLE_THP is set); however, for vDSO vmas, vma->vm_mm is NULL. > > Previously, transparent_hugepage_active() in smaps path would check > transhuge_vma_suitable() before checking these flags, which would fail for vDSO > vma since we'd take the !vma_is_anonymous() branch and find the vma (most > likely) wasn't suitably aligned (by chance ?). > > Anyways, I think we need to check vma->vm_mm. Like this? --- a/mm/huge_memory.c~mm-thp-kill-transparent_hugepage_active-fix +++ a/mm/huge_memory.c @@ -73,6 +73,9 @@ bool hugepage_vma_check(struct vm_area_s unsigned long vm_flags, bool smaps) { + if (!vma->vm_mm) + return false; + if (!transhuge_vma_enabled(vma, vm_flags)) return false; _