Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5489029pxb; Wed, 26 Jan 2022 13:14:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJyiVillugiuP5KukYo9YD+7Zf1I+SZwqTdJJ3gChtLv+J47XOlHZBMhtCLiYOu/sNwuHwue X-Received: by 2002:a63:4b4d:: with SMTP id k13mr494638pgl.423.1643231668482; Wed, 26 Jan 2022 13:14:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643231668; cv=none; d=google.com; s=arc-20160816; b=NVLzDZwox7wbCpnHgTsMXA/EBIASLokdspbwk8UA3qGw7NsGD0aGa1mAZN8JI1slB9 obHR4C2EXtImgi1eJcTFVnn/3E0xYMni19egBYHRGAyW83XjyPUK/oi5QE0wTmdZyK1t v+x9MevnTRpnHmBqxGaFkXfRUZtcM5Va49PbvZXuZZbek9hYPOm7SbN3Sv9XKvxKI2p4 R3MKY1awaeu0Hd0ccPgw99EVYm9HK/D7YkeNE+24eUow08H8GY+gu9NI3vrLF89UElRa 30cwjYDMWvO1nZ+2Nz8bbltjM4xNeULi6g5DW8h1FPvIJbW9oZe9EBQ27/gCAZblCurH JwKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=A872bzMo6IlzyAAaWw5oHBWQXder2YytjfpeZ9XG+YI=; b=nN129dDEtRC1uKzwZlykQMrH4U7XTEZhJ8iQLKaMfcYrwqtJVSBUrxNO48aVrTYpbz mjeyL9LehMhl24pjb9OKuPF1HPhNfxnorVgQmx4GHoARnGwzImHmlCzeAQ5b9OD4W9jt L4VlFrmmdAMr4CuZpGePFZxd5HRhTuJCUpxqgFQ2jE2dXpKlcc+fenSUFH6yNVbxG1dA 3ysjDo+vgYMLtLyOxrf3/i90prikcGRzLkEMq7SEU3XnDsn8gUunrcuUwwKoEkEo3n6z A5qul4weOyWL363Auc7Vb9tqLEy/wM3zXOD1756sZAMc/e21JgdFIawMEkkTYsrLBrHn yTTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=dLcrTCHg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e18si236370plj.334.2022.01.26.13.14.15; Wed, 26 Jan 2022 13:14:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=dLcrTCHg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241364AbiAZMe6 (ORCPT + 99 others); Wed, 26 Jan 2022 07:34:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241330AbiAZMe5 (ORCPT ); Wed, 26 Jan 2022 07:34:57 -0500 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BCECC06161C for ; Wed, 26 Jan 2022 04:34:57 -0800 (PST) Received: by mail-ej1-x62f.google.com with SMTP id h7so38744411ejf.1 for ; Wed, 26 Jan 2022 04:34:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=A872bzMo6IlzyAAaWw5oHBWQXder2YytjfpeZ9XG+YI=; b=dLcrTCHgZcoiBBrgo+IT+WWZcsahinvRFDXNidl+eV1OG12bGu7I6xaNL82s+EBKv2 IJjyrcfFhuwJZ1sA/nXSwuiWMJOCMjCS9lcu2VoKXklf9VT2M+F4Jpp1XqO2KtSWLTH7 iGImzI/53J51uWCaN80T3ayPBbQdrnx4TNm/O1tlhcYRIgkQgu/mKcQ1q/79rTvobqXO gPuF2b2FHMtJqlo6/Te7Q/6c5KpP0TTrTSy2UGKP4eSupuilp3YrK07yKJmwQDnS97nQ 337HDYc8smOlARoDdWP5vb9i/MHr8SUJ0rgW9IcsGJbonEk08b6gIdGrvRrt4XZ0ae+f atrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=A872bzMo6IlzyAAaWw5oHBWQXder2YytjfpeZ9XG+YI=; b=gaes7xCojweYu9U3p3/QiLwCyn96dmoOUmV5i8VRSKbVldVDDp5luMhKXJDu2fQyxK iXt0esV3iochzbrqH3XH5uJfvJfLAPlW50LR9qh0OZtjBO3loEg/mTVZidB6zE3vaOl0 j1iILm/xxYEWnRq2O1Kfp8sxdc0CX5Nl03J+nN580x5iauNE1w6F/XnG/YFC+yFQyTem Z1U84mMBfVZTp8RjIKxl4FdfdJbciwmetWHaf1zRRdWRDgbJJ/zi95XjUDFrdaBUXYtj ULbhzkFAPPm3HZZUehbRMsag6I5D9aa17r2VlA2VhhB+PXCVTNToirQeGAuNJkRcJxbJ Pn/Q== X-Gm-Message-State: AOAM533csh1YIjaL/iBDvLYjRCIvpv6tYegpaC7EpXXF/q1hZdacXx7w oxHDRxX6WvJAqgPjC4OgsohXBCBWVAa5E8sLbmaP1Q== X-Received: by 2002:a17:907:7d8c:: with SMTP id oz12mr862732ejc.320.1643200495700; Wed, 26 Jan 2022 04:34:55 -0800 (PST) MIME-Version: 1.0 References: <20220126060514.1574935-1-pasha.tatashin@soleen.com> <20220126060514.1574935-4-pasha.tatashin@soleen.com> In-Reply-To: From: Pasha Tatashin Date: Wed, 26 Jan 2022 07:34:19 -0500 Message-ID: Subject: Re: [PATCH v3 3/4] mm/khugepaged: unify collapse pmd clear, flush and free To: David Rientjes Cc: LKML , linux-mm , Andrew Morton , Paul Turner , Wei Xu , Greg Thelen , Ingo Molnar , Will Deacon , Mike Rapoport , Dave Hansen , "H. Peter Anvin" , "Aneesh Kumar K.V" , Jiri Slaby , Muchun Song , Fusion Future , Hugh Dickins , Zi Yan , Anshuman Khandual Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 26, 2022 at 1:34 AM David Rientjes wrote: > > On Wed, 26 Jan 2022, Pasha Tatashin wrote: > > > Unify the code that flushes, clears pmd entry, and frees the PTE table > > level into a new function collapse_and_free_pmd(). > > > > This clean-up is useful as in the next patch we will add another call to > > this function to iterate through PTE prior to freeing the level for page > > table check. > > > > Signed-off-by: Pasha Tatashin > > Acked-by: David Rientjes Thank you, David. > > One nit below. > > > --- > > mm/khugepaged.c | 32 ++++++++++++++++---------------- > > 1 file changed, 16 insertions(+), 16 deletions(-) > > > > diff --git a/mm/khugepaged.c b/mm/khugepaged.c > > index 35f14d0a00a6..440112355ffe 100644 > > --- a/mm/khugepaged.c > > +++ b/mm/khugepaged.c > > @@ -1416,6 +1416,17 @@ static int khugepaged_add_pte_mapped_thp(struct mm_struct *mm, > > return 0; > > } > > > > +static void collapse_and_free_pmd(struct mm_struct *mm, struct vm_area_struct *vma, > > + unsigned long addr, pmd_t *pmdp) > > +{ > > + spinlock_t *ptl = pmd_lock(vma->vm_mm, pmdp); > > + pmd_t pmd = pmdp_collapse_flush(vma, addr, pmdp); > > + > > + spin_unlock(ptl); > > No strong objection, but I think the typical style would be to declare the > local variables separately and avoid mixing the code, especially in cases > when taking locks (and not just initializing the local variables). I will address this in the next revision. Thank you, Pasha