Received: by 2002:a05:6359:322:b0:b3:69d0:12d8 with SMTP id ef34csp447727rwb; Wed, 10 Aug 2022 10:47:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR5iihIsDF2zu1BM5XC+8/aoVqphgxPVHNsy+m0BU8pj/7/5KAHQNJ0+9mu8bp8tYqaiqgGl X-Received: by 2002:a17:907:209c:b0:731:27bb:da8c with SMTP id pv28-20020a170907209c00b0073127bbda8cmr14133595ejb.555.1660153635702; Wed, 10 Aug 2022 10:47:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660153635; cv=none; d=google.com; s=arc-20160816; b=sL0o8WgcoqUPZyNqNOosY7QGE2OVqmikaEg/WEoxLmhE6wooe/a0nf65BK/5EO/1UZ qaMYo69wB/yTMxSzdtfueoZ0sm6p/wI6Ox3KbpWutB2Z76ee9dFrx2EJZJbCHbSVplOp qnYW7PM73428qaTRfIWUddEVZYZoNYRoNnpj4ujRV9nwkTbYJ5LbkFwW7XhpJ2ryLeS5 rd1ipC+vPELh3LNMdbQQ3N2LF46Q/DZgXmIpVIbXKGTxpLlljSPBx/Z9BoVbUazKSvSk QhURL+u12MD3CYu1/4D7PHofaP6/6vyuCCk0XE4Ev6bBBrTe7ytKrVCqoQDmKHp9njnO BGYw== 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=BloIoqd28Gq/iR4Kl8DFhiJxo48Wnl4+cYDJh7THU3o=; b=DkZ4ZU2ofHD81W43h7BaIqpmPHHnrSnWIVii1roYiKquvb25PUtu53UTrVIr4RoFCf pPofBQccMGxpzAXzkwauzeTChW2ip62GVtyV7M0mAC5ZC3Nqkiu03wwsMJEWkhZK9bYO e/YANAOLdsnBVe91VyGqx9aEIaokjKkhKUMEdFQuFEu6X8aaGq5yZm99wP/h8jOoGC80 R70DMrdTRYYROlhsGSxbSEsYeuP57+X0y4kF+YyD4bIvY7JvFM24sSf3dYgxap3oqiEO GFl66zdZC1SDoI9diWbUzDol1vUPcZ/MBHJK1AzLab/OE4zrJVSwj2wqWntsC4QdXzcP uPMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=J+lmDtEx; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e18-20020a17090658d200b007305b0156c9si5112051ejs.576.2022.08.10.10.46.49; Wed, 10 Aug 2022 10:47:15 -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=@gmail.com header.s=20210112 header.b=J+lmDtEx; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233203AbiHJRGi (ORCPT + 99 others); Wed, 10 Aug 2022 13:06:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232713AbiHJRGf (ORCPT ); Wed, 10 Aug 2022 13:06:35 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 750024A820 for ; Wed, 10 Aug 2022 10:06:34 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id 15-20020a17090a098f00b001f305b453feso2807014pjo.1 for ; Wed, 10 Aug 2022 10:06:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=BloIoqd28Gq/iR4Kl8DFhiJxo48Wnl4+cYDJh7THU3o=; b=J+lmDtEx1spmwcuZ6nzWNtmyWixs3iQlKNfDN9GHbj7bwZHS4cMQbFPjooczgmAi28 noJJpXytFM8RIKB8NHp+fliGadlVLNst/hyjPRLMP+3hYVf+8QDFzlQWS1fysWpJz0JD TbWYk4JzP8IUdumwwuedXE+kt3m43E1rT6SPPPJkx/7laJgMvWjE9w2M0GgCYu2+JIOK jPvzJBB08jggfJRS9Lm3GxdvpIfexx8h6llCHHLvJFDG21IrKwjyQ6jiUKR2XSkcQ1lQ ZRWokGoVdniJyH8OesMPG8L+Ipk2t5G7Yr78kywJZCIgsua3CC35c682Zwa4A4qSsXMZ 7wZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=BloIoqd28Gq/iR4Kl8DFhiJxo48Wnl4+cYDJh7THU3o=; b=JDnIYIo8PsOSbisL4rP5eRrmBjCpEfWlOQxlI1hu7UVwmdFuhAgx0IDm7phf3iaAlz zhEyrcSbQsP7aJJQT38EfUwtZRgzAY6y1ReNdi88LAh+E9QEyb7QhKhblLdkvxWW+iXH J7QaiXZZiLrXtDYy8hz1S67O0kVt0saiLDAbQdrm99NzlnYME+Yx0m2kxz+8jbpUGnvu immlcOlsf28y/Y09KXS3wh+EesvD2yLsqOdcruBEvktmMuXRhmP6mnhRS8OgTRxxTQxR Gv8FIAncW6LAGM50gJsNghHa1Ap69Tj+UgpnSX+6qxsCJ/HR+/qCKU1GQW5q2Basu+Az +BdQ== X-Gm-Message-State: ACgBeo0OaQ+d+CZOY2Hg0x1MKbruSIIAQPCQmO8WMl18Hmc+K1cVaAdt ye7t5zVSWE9yntcMz2Zwp91T7q3o+LjQTetI4TY= X-Received: by 2002:a17:90b:1b45:b0:1f3:1974:eb8 with SMTP id nv5-20020a17090b1b4500b001f319740eb8mr4645072pjb.200.1660151193845; Wed, 10 Aug 2022 10:06:33 -0700 (PDT) MIME-Version: 1.0 References: <20220809142457.4751229f@imladris.surriel.com> In-Reply-To: <20220809142457.4751229f@imladris.surriel.com> From: Yang Shi Date: Wed, 10 Aug 2022 10:06:21 -0700 Message-ID: Subject: Re: [PATCH v2] mm: align larger anonymous mappings on THP boundaries To: Rik van Riel Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, Matthew Wilcox Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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, Aug 9, 2022 at 11:25 AM Rik van Riel wrote: > > Align larger anonymous memory mappings on THP boundaries by > going through thp_get_unmapped_area if THPs are enabled for > the current process. > > With this patch, larger anonymous mappings are now THP aligned. > When a malloc library allocates a 2MB or larger arena, that > arena can now be mapped with THPs right from the start, which > can result in better TLB hit rates and execution time. > > Signed-off-by: Rik van Riel > --- > v2: avoid the chicken & egg issue with MMF_VM_HUGEPAGE (Yang Shi) Reviewed-by: Yang Shi > > mm/mmap.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/mm/mmap.c b/mm/mmap.c > index c035020d0c89..1d859893436d 100644 > --- a/mm/mmap.c > +++ b/mm/mmap.c > @@ -2229,6 +2229,9 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, > */ > pgoff = 0; > get_area = shmem_get_unmapped_area; > + } else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) { > + /* Ensures that larger anonymous mappings are THP aligned. */ > + get_area = thp_get_unmapped_area; > } > > addr = get_area(file, addr, len, pgoff, flags); > -- > 2.37.1 > >