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 837A1C433EF for ; Wed, 22 Jun 2022 17:52:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB4828E00DD; Wed, 22 Jun 2022 13:52:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D64738E00D8; Wed, 22 Jun 2022 13:52:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C04728E00DD; Wed, 22 Jun 2022 13:52:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id AEA048E00D8 for ; Wed, 22 Jun 2022 13:52:39 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 842B88112D for ; Wed, 22 Jun 2022 17:52:39 +0000 (UTC) X-FDA: 79606616838.13.3F211D8 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by imf02.hostedemail.com (Postfix) with ESMTP id E034F8001B for ; Wed, 22 Jun 2022 17:52:35 +0000 (UTC) Received: by mail-pg1-f169.google.com with SMTP id l4so16724875pgh.13 for ; Wed, 22 Jun 2022 10:52:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=CM4RfzBmVh3C+Iy74tc4MTRNqz/4SgRhoKdMoFuie3A=; b=LT5VSzIFADk3yZFFJCf2grfn5gX10ZlwVQywoHo9oWynlEqhcFpZNIO7Vo7cdrI8IH cqFVg3xMhjlIiXuobkgLZ74e7AMGUjGvhjaOXbuYdtufQLi4c1tIG4HR7fecgp+Anx0R 4SLy1Dpz+FlPvOuzvNETxs86OIdeBbr3TFGoR1iMWtiKqnzx/0+5b7oF+yUn1dbShqEM H15faq3ZdwAYOArsI+7UpCcFaMEE03T0l7zfgPGghFvTUKAiX3c/3qiNAiauHDdGyiOd C8i8pCUqe9FQkpKbyufo5Fme6LsdwY2alYOTxmk+z7uEHt3UEm7icsz1Bbn8h5DECPjw 3uqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=CM4RfzBmVh3C+Iy74tc4MTRNqz/4SgRhoKdMoFuie3A=; b=Xdfd+K0+BfhS9pkCPubW2cKjPLYir9Ys+7cZyilh6FZoVs3bqheKcs52/q32Gn2blG JNfcfsw6uf5GpNH0lhDFwIoXXtyiESvyytD5ql3+uovJ6Mplqrnh6MJRPmS/SRYtYrb3 bbbvPt5wi9pWWOWkFWnDAgNwFq6SswzurmWJUdRO5Ss3RofA0Fgvc6au97IUzmRtwmGs hKPEspXomakKNZemPMBzC36ObAzkhrYdKPEGcXwxmIx2fNgPyXYPtqEPIg6fN2bRc1BZ l4BuMjIVchkW1Ic1060urZqnPVZROTmcBLuLLhO0VPTxVWkSxkbsDKYbcTuutagnO0dc zTuA== X-Gm-Message-State: AJIora9IlYjZ3GkCTnJYD5MNcbPjQLaTKQz7SV9nLRReViW7w/V2LX4R AM6rIPU7VbEatjftc/L3MV56jg== X-Google-Smtp-Source: AGRyM1sP84E1mBLGYiykEHXI+HnhMfce8TyrVRgWTitaAG6k8H6/gMN63LEbAINlAMsVgHqPwlevSQ== X-Received: by 2002:a63:ff19:0:b0:403:7c60:ae96 with SMTP id k25-20020a63ff19000000b004037c60ae96mr3756287pgi.466.1655920335023; Wed, 22 Jun 2022 10:52:15 -0700 (PDT) Received: from google.com (55.212.185.35.bc.googleusercontent.com. [35.185.212.55]) by smtp.gmail.com with ESMTPSA id p8-20020aa78608000000b005183cf12184sm4033040pfn.133.2022.06.22.10.52.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jun 2022 10:52:14 -0700 (PDT) Date: Wed, 22 Jun 2022 10:52:10 -0700 From: Zach O'Keefe To: Andrew Morton 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: References: <20220616174840.1202070-1-shy828301@gmail.com> <20220616174840.1202070-5-shy828301@gmail.com> <20220621175412.02d90df5f381de0cd676adf8@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220621175412.02d90df5f381de0cd676adf8@linux-foundation.org> ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655920355; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=CM4RfzBmVh3C+Iy74tc4MTRNqz/4SgRhoKdMoFuie3A=; b=irXS9x3WqGIhkYCKxE9bsBfjOsm+izyo+8BuT9try9zrx87yOm+E2FgmA+TPCUW8qoEY5F PSnjpzCGZVAmWAl4LikB7ZzzaOtSfesoH3IGB/g6z6V+wHkRG/pGUjI+k6ZCndqPc/eZbP VPg+phX5sOiWUaShRQH09oS63keNTEI= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=LT5VSzIF; spf=pass (imf02.hostedemail.com: domain of zokeefe@google.com designates 209.85.215.169 as permitted sender) smtp.mailfrom=zokeefe@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655920355; a=rsa-sha256; cv=none; b=BNLHR01i8wk5gaetMSymZGuTflSYaf8XbtqpxrxFNPokCpUmue4XGnT91dZP4PPZ+df0tH BqB/qbIZHiW68uOdLq60zwTb/DWEer+FQl+Api3n009Bvg6MzRhIHm8FKuWH9ClbOxKaT2 uNY7XzNj7ZzxMymYtnX6dA9riHGnPFQ= X-Rspamd-Queue-Id: E034F8001B Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=LT5VSzIF; spf=pass (imf02.hostedemail.com: domain of zokeefe@google.com designates 209.85.215.169 as permitted sender) smtp.mailfrom=zokeefe@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspam-User: X-Stat-Signature: dr64dfzuit66mikdo5c5hzcq5qxnq1gm X-Rspamd-Server: rspam04 X-HE-Tag: 1655920355-849040 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 21 Jun 17:54, Andrew Morton wrote: > 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; > > _ > Hey Andrew, In principle, yes that would fix this. I don't know precisely how this fix will be applied, but note that the subsequent patch "mm: thp: kill __transhuge_page_enabled()" won't apply on top of this automatically. Also, I wonder if we should add a comment for future travellers who wonder what kind of vmas don't have an associated mm (it was news to me); though, I'm not sure if vDSO is the only such case (though show_map_vma() seems to think so), or if this just asking for stale comments down the road. Maybe it's fine as is. Thanks, Zach