Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4354979iog; Tue, 21 Jun 2022 18:22:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sZ/BYbJPsWGPVmT3t/6E9w79f7D++36IqDITmqCxJ/4qOuqaaczjSQSQYXag1aN8JgPZZS X-Received: by 2002:a63:8bc3:0:b0:40c:f448:17af with SMTP id j186-20020a638bc3000000b0040cf44817afmr704878pge.475.1655860939912; Tue, 21 Jun 2022 18:22:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655860939; cv=none; d=google.com; s=arc-20160816; b=QsFj/Tmuj81qR48Ihhv+mQ7YL/2b/Y6OEoV/c0Efrb1PG2I1xo23nJpuK2YxH+BpBd FJPxFAVhxpD/qyLLbZbLYIxUvCzXIrDkuvwbKzaOamVXCP4jRvAE4UEVignafbimx5P2 gbsnJVeW+ee24kVPMl+tDmq9DWzHl9UIc3q95eiGl93P0GRm26296wYs2K4c60ugqdXS edLG/MFQcwfuIE+3YpclomwOdxkl5yHzb9RoKk3BFh/CrT+qDWvNebV/J04KgoE/slJA Qivwg+UQ/C5K8txQ2H0PA+DX0w3DyT0x6PcZrWMUK/z92NriqTZdR0ODOIuONYnOyDXv lCGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=u5Uj+HH05wvm3xhv1CD+2lhxm4ez9XdPGDE/oSzp09c=; b=TQM4ChNJoX/OUx20ZQgE+9S/2NsgberW+yDVohLavONw+nlxYM8ZNEe+AZN6/CAzj8 cWLbOJqyGidBI20caSHycv2uXfryCxVxD+e4WOpP3tWWj6wr4ZoAny0dWmL9LhvEZmXU IJM/X7OGtXcswUAuDINQmvkK0EuHLiGESSdhOb3owXmejJ5SMk+CqmDKZr9tXVFqTwZD acsYFdrRJ/lAGG7+YIFh24ds4dBxjfw9eIOmm7Pfbqn4YMinUGMGXozzIl827i0TAeMy HNWlO37b0BUT2mGK0Dd1K8QDBh4L4e1hswse1hgQdaVuJmwd4xTHjhtCNVxzgPqXB3ZC lLfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=XNrLpe2+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 84-20020a630757000000b0040c9f5a0e43si12474087pgh.338.2022.06.21.18.22.05; Tue, 21 Jun 2022 18:22:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=XNrLpe2+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355339AbiFVAyb (ORCPT + 99 others); Tue, 21 Jun 2022 20:54:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232486AbiFVAya (ORCPT ); Tue, 21 Jun 2022 20:54:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AE5130555 for ; Tue, 21 Jun 2022 17:54:29 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id A911361779 for ; Wed, 22 Jun 2022 00:54:28 +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 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_RED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; _