From patchwork Wed May 15 13:19:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 10944795 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6822592A for ; Wed, 15 May 2019 13:21:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 586A428B60 for ; Wed, 15 May 2019 13:21:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 554C028B5F; Wed, 15 May 2019 13:21:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4006928B6B for ; Wed, 15 May 2019 13:21:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 321516B0006; Wed, 15 May 2019 09:21:19 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2D2276B0007; Wed, 15 May 2019 09:21:19 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C0C86B0008; Wed, 15 May 2019 09:21:19 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id DB5136B0006 for ; Wed, 15 May 2019 09:21:18 -0400 (EDT) Received: by mail-pl1-f200.google.com with SMTP id b69so1717927plb.9 for ; Wed, 15 May 2019 06:21:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:mime-version:content-transfer-encoding; bh=9TwqGxcqAmiiOZF0fMbRhR1jD/62UPXQ1qlKx2sBgIw=; b=q5oA/Y/t27p4PEXX0gnWsc6CEmbDesO+TU31c6uloUptlcm6QgJbt+XLUkUhN8Im4n hUDLvR9HCSljNW1BkgEZwnvd6kKcy+MV9VjzVKDMjLU6PStU/4hYWGCItofp2dP6bpYd 6qo2p1EDwGd8chp9XgDNYlIIkR8xTqAYbbHGqmucyODcYDD+b5mRvBVK5gVzf9NJyyc5 jKRaXhOnXpqgTh+HtSCMKakFxsGlyu81c9d8PX+2tpHXIK246vYq+6EhcYNePFMFPTTg IJIuJkuZyxVlk9Sc7r5q4rNe+SGsqk7CIf9zAYoShjC+I6343EF7FLm9DhMFjbalZfst zskg== X-Gm-Message-State: APjAAAXPNDzkzYKGoqeNqSMGWfmEvU7zCB4UdP0zpMFy5eItx1924VMr RFwSE6sGA4+xwczlYzWLG2w8nbtZRmVnk4SBtrqwXfsvbbASGAW8uXG+T0BJYS0mW0JzcSM5aTD QgWXryLNw5bCdzMNOUuX7O6T1L3ZT4yw/PlJrkJG0Gpi/2GYz+p2cxD78MqjoymiVLw== X-Received: by 2002:aa7:9ab0:: with SMTP id x16mr39880030pfi.201.1557926478347; Wed, 15 May 2019 06:21:18 -0700 (PDT) X-Received: by 2002:aa7:9ab0:: with SMTP id x16mr39879938pfi.201.1557926477323; Wed, 15 May 2019 06:21:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557926477; cv=none; d=google.com; s=arc-20160816; b=ZsKSpGymoj4nboDkiHzeoJUfZWFgcta5NkVi7rDrEfqyNuuovqgVihLNzneX/q+SVi MnLFu26rs4pzc5QexCCCTFC+3fYi/1GIA1kAYSYgVxRrjZ+gqzNixiL26nEY6qFlyFGg YeJ06z65lXTaIe28Z4S0LxqYR7U0LgATa9cGFN6qCx8bmh+l81Y+36BRd9+RXxvFZ3fh NOkCYbppewL6qH/6IXLZvGFEaogVDOHKrHqPX1KLAlDu3z5/CId1//gufN4QbsrZ9MOl JAGxkAOdvsOzmcxrNnHT4V0pjZDycXxJ+vDcOStt0e4iHJEN301x3gw3L5qDrMrKZ16u HU1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=9TwqGxcqAmiiOZF0fMbRhR1jD/62UPXQ1qlKx2sBgIw=; b=qxE+FVPTo6TraOJptkLEumI1n1cxcQgCXm3e9Sb8EkAFGm3M6ISqYsSd2O4Hh0wLjb shqg8eCTDk3e5MktMJrWQTzuz5SGkcw04qRU18cBLstDryaOF4Nt6VMf4Afmpw1bE54l Bi5d/TgRr0+hh0KZZ8nquZeVHXGccuZiddC8ArggXR2uC479Qgrp4/t1hgPJGsRmYj2i ipEIgrqg3QNZPiTz2SdyJTAYaQZOQL8YdBx4bjA2Y2Ou811veHsfS3eGZ7d3AB0GOOW3 vDH7VUVMNS4qIc47LZNgCj3bdPUJqclU4uquc2hh5FplCk/wxjNY13hNg8/uxoRFP3Ot ZbOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JlgbVq8Q; spf=pass (google.com: domain of npiggin@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=npiggin@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id a1sor1994628pgq.82.2019.05.15.06.21.17 for (Google Transport Security); Wed, 15 May 2019 06:21:17 -0700 (PDT) Received-SPF: pass (google.com: domain of npiggin@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JlgbVq8Q; spf=pass (google.com: domain of npiggin@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=npiggin@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9TwqGxcqAmiiOZF0fMbRhR1jD/62UPXQ1qlKx2sBgIw=; b=JlgbVq8Qjwpw9WAr3pAylhX1iQ/iYC2g7mT8uRosYuCwHSDM/yTMreG9tYBQVcVNyQ BC3/VjABCkHEHMUbtmJ1XRRTjFNlVYrx7pJY+4wKAQ2h1XQhtIWWQjes9+TUvLQY8GpZ 0BHAGQH2GBe2dBQhPXIAuMQwphBBnD9R55zyuQcMkNaeHWS/m7jNtzmuAXPn0TPRyl1Z QtI3c2LEu81tkSQDEm6AJtJ/McHtOdQG8QyM9WvshOaHLKxHkdoyJ+r6XLKyi3M4W+eT 6TcQq4blbNWTweaNiEeY0T+M83F934W5jcywJmVxHQcdxOlFCYLapC0SZlg61V7F44tT ZsVw== X-Google-Smtp-Source: APXvYqxAXcfJTxXroa2Tygf/+OEh2WGaMRVJDDPwfEwlvrlt/aw5en3n2OvDBvWLLEnZ8lG6AVBaFg== X-Received: by 2002:a63:8bc9:: with SMTP id j192mr43412507pge.212.1557926476914; Wed, 15 May 2019 06:21:16 -0700 (PDT) Received: from bobo.local0.net (115-64-240-98.tpgi.com.au. [115.64.240.98]) by smtp.gmail.com with ESMTPSA id a19sm2784459pgm.46.2019.05.15.06.21.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 May 2019 06:21:16 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org Cc: Nicholas Piggin , Linus Torvalds Subject: [RFC PATCH 1/5] mm: large system hash use vmalloc for size > MAX_ORDER when !hashdist Date: Wed, 15 May 2019 23:19:40 +1000 Message-Id: <20190515131944.12489-1-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP The kernel currently clamps large system hashes to MAX_ORDER when hashdist is not set, which is rather arbitrary. vmalloc space is limited on 32-bit machines, but this shouldn't result in much more used because of small physical memory. Signed-off-by: Nicholas Piggin --- mm/page_alloc.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 59661106da16..1683d54d6405 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7978,7 +7978,7 @@ void *__init alloc_large_system_hash(const char *tablename, else table = memblock_alloc_raw(size, SMP_CACHE_BYTES); - } else if (hashdist) { + } else if (get_order(size) >= MAX_ORDER || hashdist) { table = __vmalloc(size, gfp_flags, PAGE_KERNEL); } else { /* @@ -7986,10 +7986,8 @@ void *__init alloc_large_system_hash(const char *tablename, * some pages at the end of hash table which * alloc_pages_exact() automatically does */ - if (get_order(size) < MAX_ORDER) { - table = alloc_pages_exact(size, gfp_flags); - kmemleak_alloc(table, size, 1, gfp_flags); - } + table = alloc_pages_exact(size, gfp_flags); + kmemleak_alloc(table, size, 1, gfp_flags); } } while (!table && size > PAGE_SIZE && --log2qty); From patchwork Wed May 15 13:19:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 10944797 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 29767933 for ; Wed, 15 May 2019 13:21:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 182F828B82 for ; Wed, 15 May 2019 13:21:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C93828B83; Wed, 15 May 2019 13:21:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9442128B45 for ; Wed, 15 May 2019 13:21:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 850DC6B0007; Wed, 15 May 2019 09:21:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 801DB6B0008; Wed, 15 May 2019 09:21:22 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A3396B000A; Wed, 15 May 2019 09:21:22 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 328116B0007 for ; Wed, 15 May 2019 09:21:22 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id d21so1679134pfr.3 for ; Wed, 15 May 2019 06:21:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=UuF5JmpoANujb+aVXS9mdWRXSQPbwJ+7x1JTARJZaCI=; b=puPwESufVBCwjPHOxf56/SmSg0SzgBUvqvbNYtjkTnDZq6PNgzZyFmlTiqiz+Dw2J9 kXpGHrFzNpIS4mNpfei91XK48dtN2YOjsf//a6RQEjAefRt+LsazUNYFBMiM51/fTNPb AyqalvC+BQ+g1we3059dhCRq3yGz0DaJ0ofeWY1b6iPtkWtF3IsBXK0jWiaWIZ7VCVB2 0Ey+HQXYOhMZF/vYyVbmIadcOVrvDX/dZbHWlHhlWmy7aDFvSFWPksEkdnEjLF9Q2/Ga CM0YOi3kZdBE1rGlU9+f2v96XlgtWSMcwUOexLfBZLTJYScduQBiXCaLlkWEN2jGKPPt pwaA== X-Gm-Message-State: APjAAAVhygK3FtaqejfwT0XY9oeyHRKyMgRwYwbFqw1VeQhT97Z+9VOO jagImR4FwHQiustosAL6uzN1Y961bvhGXLAsnDC6XMq6/iJeMTsvS6bN+Qm9H4SnHBG3J9zbDem fL6PBU5bIOcIB1FD2VCAh6KEiU0uPpV+T379ADJAu6YfsmJzKLoHA6JiBY4TaVpB+1g== X-Received: by 2002:a65:4246:: with SMTP id d6mr1400805pgq.156.1557926481046; Wed, 15 May 2019 06:21:21 -0700 (PDT) X-Received: by 2002:a65:4246:: with SMTP id d6mr1400724pgq.156.1557926480044; Wed, 15 May 2019 06:21:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557926480; cv=none; d=google.com; s=arc-20160816; b=PDwOfDjNhg22BYM6tBNHaCRyI20sO+HmBl1VZIVX+lbx6Gv8ssqTBa8Ktq53ODlx+Y 6vTLTls9hJnQ3hnejo70yuLihtWTRlPCGFmT+vLob69OnwK9VKyyu1kLh2iYWilonzw/ U+UMna5WUrgYA5vy2SU42baUVVgZUWWzDkTFo8lMSvRlIjTgqLlv4Np6aKG/sz82TaSA QxUbklQ1Tr4z2c2qsLlSsUK+VJOqxCUMFQlsThIpfdqlHh9TfwEm/prPo/WoizcFu57e 82pJSzmQ9iPD5o1BlJMVX7ACigNDrSSY2s+lQRdqf7IoVjWcgIPa9Ba5ZzLRmOK7oy2A RZ1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=UuF5JmpoANujb+aVXS9mdWRXSQPbwJ+7x1JTARJZaCI=; b=O85zJYf0owFbr4hkCkuZ7sdt06Q3wJqYbRqObIx4j7zXbfLRUBrKH6SygjqOR3du24 6EXSbegJ0bTSSMK3zVeop3eDb8aQy+6Lcxx09dfE7t/NmYdSXHc1bJWKRT+ONOAp1FVe I/jq3efS750AkuQFN8gn2mqeWE8ScpEHJZjxKBn4FxJIDsnLpdG6EJ4r5R9BBB4ws8qW c7ZaUF3O4m7HW8um8H/zJfitawXzY51y0PS1LnfnTSMjwttYyZENmQj/QYBEc/ZxIQpW FobGrBh7ENd4l2UIJC82Q5ZzcSyero0/1+9ULgwEXMp7vrpfkv4Eisf4UvSi27bTKNix bD8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=b4tRdBqZ; spf=pass (google.com: domain of npiggin@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=npiggin@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id z134sor1963363pgz.86.2019.05.15.06.21.19 for (Google Transport Security); Wed, 15 May 2019 06:21:20 -0700 (PDT) Received-SPF: pass (google.com: domain of npiggin@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=b4tRdBqZ; spf=pass (google.com: domain of npiggin@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=npiggin@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UuF5JmpoANujb+aVXS9mdWRXSQPbwJ+7x1JTARJZaCI=; b=b4tRdBqZOnTV18iCcCZa7NI9wBo8DwPblHdIVe4RYrU0u2KifznkLqFV/iHZ93/I2j Nm+VCQWRfhC3NlNqs05EzSO8FETyO3wR8RGFbw040/MwXNM739LLrzWe6gErbtdEHc6l wYGGaK6mm0B/Ow8oFu+4Tt/qCuAF8w7Zw7QMPqxQhn21yOpPC/H+kyB9ntng4/E6lFl5 MdrET+qd6g7B5rX9AlwU61oF41qg35xCdO3NgmxaWSol1vxFlSaIGlTlYFGXqYIcik8G K+JBpFvT/VGrD0SLLfiWDahMevjQhfaB8Wml5Pux8zBujGhMAoAbtoS0dLW/63y+l9FF kq9Q== X-Google-Smtp-Source: APXvYqw37IsZcBf13+bcc6eMW9pqha/YVVnPh5EBfP+6sp+7xg2XlzfvmxEuPyF4yfFGXkhrQEPTEg== X-Received: by 2002:a63:d949:: with SMTP id e9mr43714694pgj.437.1557926479788; Wed, 15 May 2019 06:21:19 -0700 (PDT) Received: from bobo.local0.net (115-64-240-98.tpgi.com.au. [115.64.240.98]) by smtp.gmail.com with ESMTPSA id a19sm2784459pgm.46.2019.05.15.06.21.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 May 2019 06:21:19 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org Cc: Nicholas Piggin , Linus Torvalds Subject: [RFC PATCH 2/5] mm: large system hash avoid vmap for non-NUMA machines when hashdist Date: Wed, 15 May 2019 23:19:41 +1000 Message-Id: <20190515131944.12489-2-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190515131944.12489-1-npiggin@gmail.com> References: <20190515131944.12489-1-npiggin@gmail.com> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP hashdist currently always uses vmalloc when hashdist is true. When there is only 1 online node and size <= MAX_ORDER, vmalloc can be avoided. Signed-off-by: Nicholas Piggin --- mm/page_alloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 1683d54d6405..1312d4db5602 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7978,7 +7978,8 @@ void *__init alloc_large_system_hash(const char *tablename, else table = memblock_alloc_raw(size, SMP_CACHE_BYTES); - } else if (get_order(size) >= MAX_ORDER || hashdist) { + } else if (get_order(size) >= MAX_ORDER || + (hashdist && num_online_nodes() > 1)) { table = __vmalloc(size, gfp_flags, PAGE_KERNEL); } else { /* From patchwork Wed May 15 13:19:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 10944799 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 44AAC933 for ; Wed, 15 May 2019 13:21:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F56128B26 for ; Wed, 15 May 2019 13:21:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2BA1428B20; Wed, 15 May 2019 13:21:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4310028B6B for ; Wed, 15 May 2019 13:21:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BD6476B0008; Wed, 15 May 2019 09:21:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B5E026B000A; Wed, 15 May 2019 09:21:24 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A283A6B000C; Wed, 15 May 2019 09:21:24 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id 689896B0008 for ; Wed, 15 May 2019 09:21:24 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id b69so1718064plb.9 for ; Wed, 15 May 2019 06:21:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ip56oQp/MiPwbfoD/lJd9v+rKbeF28/RCtEcjd99m7M=; b=IPd0s26v0gq48HklCR5FBF0FCaDYjICGSEzCnIL+Q/qgahDJEpDD0hynkHa3aDkO8J sPJtqagqYf5jG3WMEX9094PRdyh7big8xv+wNhSp0gUKeTTXs3XYfmDH2OxWcQ9GrPM3 poZSFqaQjWppr9Q/SL8M9N9RCt6SvahLJen/la6qcQkyqFy08e9oQpli7PTKpIedNi44 d9fnDHo3LJag8qwrHOIjdnN2B5USNDQVBTAKmbfkjP9jyxhXLiGiZ+tQ9gUeOSdR5zlw f1NNzgOJJoOfFX9h+wiqFhzUPhmhyE+YoqorShbpB9SwxJGV5+h3o3ZYUQ+rjWQLxXm4 bVMw== X-Gm-Message-State: APjAAAX/Cn6pY6dD73hHlee7q/3CTpjzRPIgJe3L98+Yv6Trm231PGCj duHqtuPjNTO62xh3hwganWDOhYKmReiBxhY5kw8SH0orMODb4BxI64KXipuUekBqvrPlyNsIbHv sd7ZQPOFsO9BdpXGTBDfRc1q5k7lsgMmgohkYswtIgKsvHdKj8EuuimlL2FNBySUCOw== X-Received: by 2002:a17:902:2883:: with SMTP id f3mr18193618plb.26.1557926484074; Wed, 15 May 2019 06:21:24 -0700 (PDT) X-Received: by 2002:a17:902:2883:: with SMTP id f3mr18193534plb.26.1557926482999; Wed, 15 May 2019 06:21:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557926482; cv=none; d=google.com; s=arc-20160816; b=ceMbgGjdcaifuQGIoKlpIcS/E3aUd0yhqAAWPx+C8dR+XBRZ71F/qwMjtNcvZsrplT 8Ic3fnykr6VGiwm0xUfly/7h2MhHVSws0qLpG+FVLfuf3sBgi4BaWwdh1Z3D3Q/hZ1+H 0KZoWq9czewLdfzlJRo+H0UM9owph9dgaFtCTAlyAb8cT37jIrdCwC7pWOYVNFBiLj+T CkrOfHoRMAZkFlpdtx+717AU+0L0VKgN8czrBMSBUZASU25I6GXzWVkqMNQEgbNuN2b4 Z4RvkngZcyNQ5MvsDQHf9+BRcQb63sUBeOIvzfWt4D0ZWGl9u6rrVJiI0FfhVsnYsezg JdGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=ip56oQp/MiPwbfoD/lJd9v+rKbeF28/RCtEcjd99m7M=; b=jw8xLdjGroZ15fikLUTxhd0ijwG26hBRt1LlXpijHtlY9VGCMx7XHa7AhF3CzpWQAR rCh/MPb3IrXj507UA15iBN+izLWvnQXTVGvjO1Xw/nLplZWYVL2W/AOWkhc8Bw0pdftQ QAeV7QYmfkWry1T9aZs/PL+soBhQsszwjCPKfqIUpZWCUi8FsmnYkmFA9XnKKGr5Scs2 j9otxl0Tudnauyx60RbAe3vcsmDJhhlLb4gcPybanPizoxZ/4SW7OeNjbDKBlDPWC7w3 CHT+UW1DAmL1ZoPG025v2SOuLnxUCzw2assE139sxGWZGbJeNFfVvkx+keRFkoLZIecp S6NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fLMePcIC; spf=pass (google.com: domain of npiggin@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=npiggin@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id s193sor2401716pfs.6.2019.05.15.06.21.22 for (Google Transport Security); Wed, 15 May 2019 06:21:22 -0700 (PDT) Received-SPF: pass (google.com: domain of npiggin@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fLMePcIC; spf=pass (google.com: domain of npiggin@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=npiggin@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ip56oQp/MiPwbfoD/lJd9v+rKbeF28/RCtEcjd99m7M=; b=fLMePcICUHw6bk34/HXTSNEnZQbib95S4xjsXp2eaJHwSjzUE84qBl+TWgWMe/Pdor y0sz+OT/XjfRQrRYK3LAU1EZGMMqgZ4M/T2tMhbmreGnDXtxAWDLvgVWQbwvl3fswdf4 FCfcJqKFs624EhoATPsqTNVdwsNi+qhQ7tVFXSK/2548PgibNFqugO77ElNnmfr+OE4j 6G51bHLaSHvAox0YBnbspdV1V7icCN96rCQj25rhHVbPzmBMw9VOxtIMtSyjDGJHAipB x2lWSS7PMTp0MRVljrUt+p+MIlstq8t7yr4XahdjehAreJ3+NNiGkE4UuAGqil3hN1SC 3HVg== X-Google-Smtp-Source: APXvYqw0njhCj9KpkSNJkxMjl1+53gGa9zdHsWSP7PpJ5b02y8wyAiMtjyVWx7Mmq1iIEDkXr0Zt5Q== X-Received: by 2002:aa7:8a87:: with SMTP id a7mr9083441pfc.53.1557926482683; Wed, 15 May 2019 06:21:22 -0700 (PDT) Received: from bobo.local0.net (115-64-240-98.tpgi.com.au. [115.64.240.98]) by smtp.gmail.com with ESMTPSA id a19sm2784459pgm.46.2019.05.15.06.21.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 May 2019 06:21:22 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org Cc: Nicholas Piggin , Linus Torvalds Subject: [RFC PATCH 3/5] mm/vmalloc: Hugepage vmalloc mappings Date: Wed, 15 May 2019 23:19:42 +1000 Message-Id: <20190515131944.12489-3-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190515131944.12489-1-npiggin@gmail.com> References: <20190515131944.12489-1-npiggin@gmail.com> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP This appears to help cached git diff performance by about 5% on a POWER9 (with 32MB dentry cache hash). Profiling git diff dTLB misses with a vanilla kernel: 81.75% git [kernel.vmlinux] [k] __d_lookup_rcu 7.21% git [kernel.vmlinux] [k] strncpy_from_user 1.77% git [kernel.vmlinux] [k] find_get_entry 1.59% git [kernel.vmlinux] [k] kmem_cache_free 40,168 dTLB-miss 0.100342754 seconds time elapsed After this patch (and the subsequent powerpc HUGE_VMAP patches), the dentry cache hash gets mapped with 2MB pages: 2,987 dTLB-miss 0.095933138 seconds time elapsed elapsed time improvement isn't too scientific but seems consistent, TLB misses certainly improves an order of magnitude. My laptop takes a lot of misses here too, so x86 would be interesting to test, I think it should just work there. --- include/linux/vmalloc.h | 1 + mm/vmalloc.c | 87 +++++++++++++++++++++++++++-------------- 2 files changed, 59 insertions(+), 29 deletions(-) diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index c6eebb839552..029635560306 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -42,6 +42,7 @@ struct vm_struct { unsigned long size; unsigned long flags; struct page **pages; + unsigned int page_shift; unsigned int nr_pages; phys_addr_t phys_addr; const void *caller; diff --git a/mm/vmalloc.c b/mm/vmalloc.c index e5e9e1fcac01..c9ba88768bca 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -216,32 +216,34 @@ static int vmap_p4d_range(pgd_t *pgd, unsigned long addr, * Ie. pte at addr+N*PAGE_SIZE shall point to pfn corresponding to pages[N] */ static int vmap_page_range_noflush(unsigned long start, unsigned long end, - pgprot_t prot, struct page **pages) + pgprot_t prot, struct page **pages, + unsigned int page_shift) { - pgd_t *pgd; - unsigned long next; unsigned long addr = start; - int err = 0; - int nr = 0; + unsigned int i, nr = (end - start) >> (PAGE_SHIFT + page_shift); - BUG_ON(addr >= end); - pgd = pgd_offset_k(addr); - do { - next = pgd_addr_end(addr, end); - err = vmap_p4d_range(pgd, addr, next, prot, pages, &nr); + for (i = 0; i < nr; i++) { + int err; + + err = ioremap_page_range(addr, + addr + (PAGE_SIZE << page_shift), + __pa(page_address(pages[i])), prot); if (err) return err; - } while (pgd++, addr = next, addr != end); + + addr += PAGE_SIZE << page_shift; + } return nr; } static int vmap_page_range(unsigned long start, unsigned long end, - pgprot_t prot, struct page **pages) + pgprot_t prot, struct page **pages, + unsigned int page_shift) { int ret; - ret = vmap_page_range_noflush(start, end, prot, pages); + ret = vmap_page_range_noflush(start, end, prot, pages, page_shift); flush_cache_vmap(start, end); return ret; } @@ -1189,7 +1191,7 @@ void *vm_map_ram(struct page **pages, unsigned int count, int node, pgprot_t pro addr = va->va_start; mem = (void *)addr; } - if (vmap_page_range(addr, addr + size, prot, pages) < 0) { + if (vmap_page_range(addr, addr + size, prot, pages, 0) < 0) { vm_unmap_ram(mem, count); return NULL; } @@ -1305,7 +1307,7 @@ void __init vmalloc_init(void) int map_kernel_range_noflush(unsigned long addr, unsigned long size, pgprot_t prot, struct page **pages) { - return vmap_page_range_noflush(addr, addr + size, prot, pages); + return vmap_page_range_noflush(addr, addr + size, prot, pages, 0); } /** @@ -1352,7 +1354,7 @@ int map_vm_area(struct vm_struct *area, pgprot_t prot, struct page **pages) unsigned long end = addr + get_vm_area_size(area); int err; - err = vmap_page_range(addr, end, prot, pages); + err = vmap_page_range(addr, end, prot, pages, 0); return err > 0 ? 0 : err; } @@ -1395,8 +1397,9 @@ static struct vm_struct *__get_vm_area_node(unsigned long size, return NULL; if (flags & VM_IOREMAP) - align = 1ul << clamp_t(int, get_count_order_long(size), - PAGE_SHIFT, IOREMAP_MAX_ORDER); + align = max(align, + 1ul << clamp_t(int, get_count_order_long(size), + PAGE_SHIFT, IOREMAP_MAX_ORDER)); area = kzalloc_node(sizeof(*area), gfp_mask & GFP_RECLAIM_MASK, node); if (unlikely(!area)) @@ -1608,7 +1611,7 @@ static void __vunmap(const void *addr, int deallocate_pages) struct page *page = area->pages[i]; BUG_ON(!page); - __free_pages(page, 0); + __free_pages(page, area->page_shift); } kvfree(area->pages); @@ -1751,14 +1754,17 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, pgprot_t prot, int node) { struct page **pages; + unsigned long addr = (unsigned long)area->addr; + unsigned long size = get_vm_area_size(area); + unsigned int page_shift = area->page_shift; + unsigned int shift = page_shift + PAGE_SHIFT; unsigned int nr_pages, array_size, i; const gfp_t nested_gfp = (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO; const gfp_t alloc_mask = gfp_mask | __GFP_NOWARN; const gfp_t highmem_mask = (gfp_mask & (GFP_DMA | GFP_DMA32)) ? - 0 : - __GFP_HIGHMEM; + 0 : __GFP_HIGHMEM; - nr_pages = get_vm_area_size(area) >> PAGE_SHIFT; + nr_pages = size >> shift; array_size = (nr_pages * sizeof(struct page *)); area->nr_pages = nr_pages; @@ -1779,10 +1785,8 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, for (i = 0; i < area->nr_pages; i++) { struct page *page; - if (node == NUMA_NO_NODE) - page = alloc_page(alloc_mask|highmem_mask); - else - page = alloc_pages_node(node, alloc_mask|highmem_mask, 0); + page = alloc_pages_node(node, + alloc_mask|highmem_mask, page_shift); if (unlikely(!page)) { /* Successfully allocated i pages, free them in __vunmap() */ @@ -1794,8 +1798,9 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, cond_resched(); } - if (map_vm_area(area, prot, pages)) + if (vmap_page_range(addr, addr + size, prot, pages, page_shift) < 0) goto fail; + return area->addr; fail: @@ -1832,19 +1837,35 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align, struct vm_struct *area; void *addr; unsigned long real_size = size; + unsigned long real_align = align; + unsigned long size_per_node; + unsigned int shift; size = PAGE_ALIGN(size); if (!size || (size >> PAGE_SHIFT) > totalram_pages()) goto fail; + size_per_node = size; + if (node == NUMA_NO_NODE) + size_per_node /= num_online_nodes(); + if (size_per_node >= PMD_SIZE) + shift = PMD_SHIFT; + else + shift = PAGE_SHIFT; +again: + align = max(real_align, 1UL << shift); + size = ALIGN(real_size, align); + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED | vm_flags, start, end, node, gfp_mask, caller); if (!area) goto fail; + area->page_shift = shift - PAGE_SHIFT; + addr = __vmalloc_area_node(area, gfp_mask, prot, node); if (!addr) - return NULL; + goto fail; /* * In this function, newly allocated vm_struct has VM_UNINITIALIZED @@ -1858,8 +1879,16 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align, return addr; fail: - warn_alloc(gfp_mask, NULL, + if (shift == PMD_SHIFT) { + shift = PAGE_SHIFT; + goto again; + } + + if (!area) { + /* Warn for area allocation, page allocations already warn */ + warn_alloc(gfp_mask, NULL, "vmalloc: allocation failure: %lu bytes", real_size); + } return NULL; } From patchwork Wed May 15 13:19:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 10944801 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F80B13AD for ; Wed, 15 May 2019 13:21:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F27F0289D7 for ; Wed, 15 May 2019 13:21:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0AD828B26; Wed, 15 May 2019 13:21:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60ABE28A6B for ; Wed, 15 May 2019 13:21:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF7606B000A; Wed, 15 May 2019 09:21:27 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DA9ED6B000C; Wed, 15 May 2019 09:21:27 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C48E46B000D; Wed, 15 May 2019 09:21:27 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 8C8D46B000A for ; Wed, 15 May 2019 09:21:27 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id 5so1662005pff.11 for ; Wed, 15 May 2019 06:21:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=bwCbazG0uWpeHHq16h61suXp9iNQSDKrijvI5Xb8k5A=; b=k8bHuv9MEoEb33mdq2k6js5KPWYQuQDDVEKMQes8ZjwXamK4K1lcZ4BLF2CFpS9KRg O9omgnTNLTX74R8T7CMWlzmGuKKsQqCgYWcEP6WWsotMhm3FPGG1Zq1PxUcB7K0BleDm wtdFnY+9m7rJNDlo6KiyqUs6FWUN7BfJmwuec+npdbI4wELdFKEhrPU2pfwDvTaGHzRA NA6At3e7wH52lIxoT4lOBwFCI9bQ5iSJYV163KhGF+OdMQBON5jq+CDdKXVeujkQIGlS 85sGYsdWT8q/01hggHwR9Po/LP1orZjG08QjrHpBtnp+2V4VVDsryDPmKLZnmuYFWUy0 FbWA== X-Gm-Message-State: APjAAAVCM29WMvbM2dGfHYvAiHnNWkFWmxV1D27gZN4/kZuWxh9qPDZp VWis1SzVyWvQOLAY5B9Ry1KNDv4o1h15qdj13J8cVtJE0o9Aki3BIb6ro4FSNewR0OxrpYd4Vp0 vo3mw3D3Pg7DGfzg7qZo2Tcx0S6WbSb9Ot1vw9a9vKC/LD2uv+u20dsetzba3oz9HZg== X-Received: by 2002:a65:62d2:: with SMTP id m18mr43988682pgv.122.1557926487233; Wed, 15 May 2019 06:21:27 -0700 (PDT) X-Received: by 2002:a65:62d2:: with SMTP id m18mr43988568pgv.122.1557926485817; Wed, 15 May 2019 06:21:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557926485; cv=none; d=google.com; s=arc-20160816; b=wyVXkeawRJBegrNwAH6ry38yRavgbfD0joWRojlmJUSAlcONXojhlFRue97zvGnUzM Gtsp9bi2b51HtNv20chK3aY4vo0NEgB0vIhM91vF8OCqiciIkPYjZtTe4x5UYmh/JPPp ogjFE0Z0apPlNeXAEQfFmYQQAMEfONvCv+2T+JjNkJ3dkMlQQBBTfth+bmrggJRkOp3l pHspDW7mQBLV4D5aQI8/UcV2zFHUePx1IYeZJOwi5qImuS/RysWsTZ7fEqzHB7LX4OiG 3fdyVPCXjV6LVMFBFlobOBAeQbPm2FkmhEhB5ou4X0GBa9I8B9mmWGZeTD5zOITJQ8D4 /afg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=bwCbazG0uWpeHHq16h61suXp9iNQSDKrijvI5Xb8k5A=; b=SQTWdTMNQec2rU2oPll/fmxG7CP1D4iXMVQLQLwzv6Yu/YpHmOk1/HXEAcw9oYW4AL VpHAuVXvwcGqdyKwA/KL1NtzS3spI6+YKW2sdihwGTygtEEqkfJX1PM1wi1GPohxpz6Q VexbcKMAOTlUJ18MN/NEqcA3Hyf+HEDQ4US+fK7iDWMIpPjvWJ1yDBgbEqN0GlT8tXCa uJhgh0OlT7DJ+ldD9eOyyGBCQslKIJoPpmGqUK7rLm5+yRpPHBi4HrSPOPXj8ZK7pOzx nmkGgSv/yDG3TqE0ojMr62dkcJiYqw35LJeFxZ/eFLvKmfkEUN8SZ+cAbLlPIW/7z6pv p0Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Hcwi14Q2; spf=pass (google.com: domain of npiggin@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=npiggin@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id j15sor2355175pfd.32.2019.05.15.06.21.25 for (Google Transport Security); Wed, 15 May 2019 06:21:25 -0700 (PDT) Received-SPF: pass (google.com: domain of npiggin@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Hcwi14Q2; spf=pass (google.com: domain of npiggin@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=npiggin@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bwCbazG0uWpeHHq16h61suXp9iNQSDKrijvI5Xb8k5A=; b=Hcwi14Q2tGdVL2zCKha7YAmgbnjBfn0I+F4J0mIrtvPa2xNDi1kWRnxlZmsp29p/u/ a2vEykX7CJ7AQwG714ATKj2Q7EDExwSFQTK2sVDyrP9mS+gcYt47vK2E08+WUNzMlRCm mPZ25kRrfrTrk4WEq6BmcgWePQHHz4h1vgLp2fQoj70GI6IBMWc3GG8ASc3dYSjt5c78 ivA348YjsJGXM6E254fAy2igbikZxE08ct7OMzNDbYQidTUnJw4fu+/5QwqbAjkMOgCQ IEVq3KCOmUEIhcd8WMbAXvCr5OqVLfZRDuWRGp/GukYllQTM4rCy+OP8LJaiNvKDHzX1 9wdQ== X-Google-Smtp-Source: APXvYqzrGvRl04leG3wMiKC5XwoMrKTT0j4sN+ztWjxzzL/exH73j2Kp+fjMcn3xSXwRLWO2cGw2BQ== X-Received: by 2002:a62:7d8e:: with SMTP id y136mr25109171pfc.224.1557926485554; Wed, 15 May 2019 06:21:25 -0700 (PDT) Received: from bobo.local0.net (115-64-240-98.tpgi.com.au. [115.64.240.98]) by smtp.gmail.com with ESMTPSA id a19sm2784459pgm.46.2019.05.15.06.21.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 May 2019 06:21:25 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org Cc: Nicholas Piggin , Linus Torvalds Subject: [RFC PATCH 4/5] powerpc/64s/radix: Enable HAVE_ARCH_HUGE_VMAP Date: Wed, 15 May 2019 23:19:43 +1000 Message-Id: <20190515131944.12489-4-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190515131944.12489-1-npiggin@gmail.com> References: <20190515131944.12489-1-npiggin@gmail.com> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP This does not actually enable huge vmap mappings, because powerpc/64 ioremap does not call ioremap_page_range, but it is required before implementing huge mappings in ioremap, because the generic vunmap code needs to cope with them. Signed-off-by: Nicholas Piggin --- arch/powerpc/Kconfig | 1 + arch/powerpc/mm/book3s64/radix_pgtable.c | 93 ++++++++++++++++++++++++ 2 files changed, 94 insertions(+) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index d7996cfaceca..ffac84600e0e 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -166,6 +166,7 @@ config PPC select GENERIC_STRNLEN_USER select GENERIC_TIME_VSYSCALL select HAVE_ARCH_AUDITSYSCALL + select HAVE_ARCH_HUGE_VMAP if PPC_BOOK3S_64 && PPC_RADIX_MMU select HAVE_ARCH_JUMP_LABEL select HAVE_ARCH_KASAN if PPC32 select HAVE_ARCH_KGDB diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c index c9bcf428dd2b..3bc9ade56277 100644 --- a/arch/powerpc/mm/book3s64/radix_pgtable.c +++ b/arch/powerpc/mm/book3s64/radix_pgtable.c @@ -1122,3 +1122,96 @@ void radix__ptep_modify_prot_commit(struct vm_area_struct *vma, set_pte_at(mm, addr, ptep, pte); } + +int __init arch_ioremap_pud_supported(void) +{ + return radix_enabled(); +} + +int __init arch_ioremap_pmd_supported(void) +{ + return radix_enabled(); +} + +int p4d_free_pud_page(p4d_t *p4d, unsigned long addr) +{ + return 0; +} + +int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot) +{ + pte_t *ptep = (pte_t *)pud; + pte_t new_pud = pfn_pte(__phys_to_pfn(addr), prot); + + set_pte_at(&init_mm, 0 /* radix unused */, ptep, new_pud); + + return 1; +} + +int pud_clear_huge(pud_t *pud) +{ + if (pud_huge(*pud)) { + pud_clear(pud); + return 1; + } + + return 0; +} + +int pud_free_pmd_page(pud_t *pud, unsigned long addr) +{ + pmd_t *pmd; + int i; + + pmd = (pmd_t *)pud_page_vaddr(*pud); + pud_clear(pud); + + flush_tlb_kernel_range(addr, addr + PUD_SIZE); + + for (i = 0; i < PTRS_PER_PMD; i++) { + if (!pmd_none(pmd[i])) { + pte_t *pte; + pte = (pte_t *)pmd_page_vaddr(pmd[i]); + + pte_free_kernel(&init_mm, pte); + } + } + + pmd_free(&init_mm, pmd); + + return 1; +} + +int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot) +{ + pte_t *ptep = (pte_t *)pmd; + pte_t new_pmd = pfn_pte(__phys_to_pfn(addr), prot); + + set_pte_at(&init_mm, 0 /* radix unused */, ptep, new_pmd); + + return 1; +} + +int pmd_clear_huge(pmd_t *pmd) +{ + if (pmd_huge(*pmd)) { + pmd_clear(pmd); + return 1; + } + + return 0; +} + +int pmd_free_pte_page(pmd_t *pmd, unsigned long addr) +{ + pte_t *pte; + + pte = (pte_t *)pmd_page_vaddr(*pmd); + pmd_clear(pmd); + + flush_tlb_kernel_range(addr, addr + PMD_SIZE); + + pte_free_kernel(&init_mm, pte); + + return 1; +} From patchwork Wed May 15 13:19:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 10944803 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6E03D13AD for ; Wed, 15 May 2019 13:21:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5EA2928AB6 for ; Wed, 15 May 2019 13:21:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5AD2128B62; Wed, 15 May 2019 13:21:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A03E128AD6 for ; Wed, 15 May 2019 13:21:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 089556B000C; Wed, 15 May 2019 09:21:31 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 039EF6B000D; Wed, 15 May 2019 09:21:30 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD1B56B000E; Wed, 15 May 2019 09:21:30 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id A32D66B000C for ; Wed, 15 May 2019 09:21:30 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id 123so1857772pgh.17 for ; Wed, 15 May 2019 06:21:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=F56UeRM9+QYDMfaKmt6HoAUehngERsrruwV76IERiz0=; b=JlCKBMo/JgjwPXCnaCPWuYITPsWIfLWFOp3tf///Q50TUrqwxFjyJN3r+hjYAKxCke Vqg80HeNqfWRu8JHjGcmbLiFmSAurmcFhvlwqF7+4CgqG3vIxk/PR378RpWvbGzoAn6e OQWlwMJoQSPxTyO3G4QaRSI59QvrVYlDYaUysRMWnH8vd5hSBK77vob8dVhuUJWFOEDS 7FJO1izGISfWiUC5QVXkkb+xPXjqaqMved6TtK9ZM61AVgAFGvNTdvrgZyls3I7jroKo e0HimvEZJr++3kgDFZeqv/Ino6hrPIvS6nES2e5Oq3sDCAXfyfpgNIEdsdqCqXA9YKj7 kCVg== X-Gm-Message-State: APjAAAVttLmZMsAytbPjd4POJ6gtvAubJ5mJrC7bGvi/RYgVpOaEh9RZ ys5MkAP26kbFi1Pc4AhMTq51myoICQCseMx8QpE11iN/h8AxpJrQ8igxEExNGybcVkJozpbm9kM FRm8+HdhGsc54TX16DuU85cBjeofuXqJwHOc/RMEgAQSO0aPoYR+MjRD51YKc43f5AQ== X-Received: by 2002:a63:f806:: with SMTP id n6mr44082402pgh.242.1557926490169; Wed, 15 May 2019 06:21:30 -0700 (PDT) X-Received: by 2002:a63:f806:: with SMTP id n6mr44082304pgh.242.1557926488955; Wed, 15 May 2019 06:21:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557926488; cv=none; d=google.com; s=arc-20160816; b=LlYPxm7SELuzxYeOjbCqrh5P33eTLzqOqkh8IAFHnDAmobx1Yountucmml3HDKcTGP TFlQnGoqDrhY146SI1HjvCSYsoJFxmV3FB4W9qAjHhB1BPx/R9iStxw3UbWoFr8yTWl4 40r7d8PNx6P6qnCsZga7/Epspy6SnoGpuC1OIrmKa11eNuKrp0pkiOSeIS1FRGFA6FAA znbnOKeV7mqEvCt7P4dPEGnNrlYOcTgZupMRCYQbhEhqquCco4eGI6NSQMu5ag/KzxaL mGieBcPG1N3LSV13O0R8psxVgmLVG9Sv6khYags7r68KD6V3AwHbwh7rSIqZHVg84bKb NTUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=F56UeRM9+QYDMfaKmt6HoAUehngERsrruwV76IERiz0=; b=ugS2NaDeWIIgf4mfaHtHj0Q1F4bTMMB5h26XdFSx+V1PkjLF/paEJf2OUbknEL4D1t sK2GDklLTBQFyTKwhZetjGgNU14jRA3qdeDvi5XGkhzlKMfunWddEufzxW9pnZqXLsjG ij1trWWHs/KsTarRuryv4Oh7DbPdb6nQq/2jj3ncB6BZs0PeKm5aNE0TdX5GKdesfqBN w3OodYJQgTnl1RXvNqWjxoRxkYdC/w8dU9feBsJt4zHIrw4suxnyHvTBxFyO5kPfd593 jMp7jiFFRqs8j3fNcTE96kdE+tALNTf8csQg08OOPmxA2aC5Lx4iAuLm7v2HFm2ole8r cakA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EnXZgfrE; spf=pass (google.com: domain of npiggin@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=npiggin@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id v23sor2019418pgc.6.2019.05.15.06.21.28 for (Google Transport Security); Wed, 15 May 2019 06:21:28 -0700 (PDT) Received-SPF: pass (google.com: domain of npiggin@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EnXZgfrE; spf=pass (google.com: domain of npiggin@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=npiggin@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=F56UeRM9+QYDMfaKmt6HoAUehngERsrruwV76IERiz0=; b=EnXZgfrE9ptE7/0LNjdYsc/YDM7sqSD5aCEtxoZtJAZIW1hcwtm+ySiloTvErKAw8p vNyxIyyextQQsrHNEWttfI5X89lSErLIXLUjqUWJCJLAVrFHgOjoZAT4d4sK38Rb/XFX UhtKIcbSwDiFN63UIGX3zTIzT4QbS75CPXH26G4v7nnPxahaYQ4x7cERq1rC8Qq5c0Ug 4ojA+2GvmOfLYBD1KltINcBxdKEvsTR3ZVlJZ7JZjEXO0psx4akGXcApVJJC5ffkAlo7 e7MmTH6kllp+sE4y/9oUaoqHK7oTrD1uQYZjt6C77QNYAB46orbIVcVNQxHxCWQ1B4S2 l6Tw== X-Google-Smtp-Source: APXvYqx9pRh7/Lft1BW35lbNk8d/eVJJbgQXZdep4WpYEIJ5ohMJcto076tmYlbXhID7nMQmyogIrg== X-Received: by 2002:a65:478a:: with SMTP id e10mr44277114pgs.310.1557926488724; Wed, 15 May 2019 06:21:28 -0700 (PDT) Received: from bobo.local0.net (115-64-240-98.tpgi.com.au. [115.64.240.98]) by smtp.gmail.com with ESMTPSA id a19sm2784459pgm.46.2019.05.15.06.21.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 May 2019 06:21:28 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org Cc: Nicholas Piggin , Linus Torvalds Subject: [RFC PATCH 5/5] powerpc/64s/radix: iomap use huge page mappings Date: Wed, 15 May 2019 23:19:44 +1000 Message-Id: <20190515131944.12489-5-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190515131944.12489-1-npiggin@gmail.com> References: <20190515131944.12489-1-npiggin@gmail.com> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/book3s/64/pgtable.h | 8 +++ arch/powerpc/mm/pgtable_64.c | 54 +++++++++++++++++--- 2 files changed, 56 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index 7dede2e34b70..93b8a99df88e 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -274,6 +274,14 @@ extern unsigned long __vmalloc_end; #define VMALLOC_START __vmalloc_start #define VMALLOC_END __vmalloc_end +static inline unsigned int ioremap_max_order(void) +{ + if (radix_enabled()) + return PUD_SHIFT; + return 7 + PAGE_SHIFT; /* default from linux/vmalloc.h */ +} +#define IOREMAP_MAX_ORDER ({ ioremap_max_order();}) + extern unsigned long __kernel_virt_start; extern unsigned long __kernel_virt_size; extern unsigned long __kernel_io_start; diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c index d2d976ff8a0e..f660116251e6 100644 --- a/arch/powerpc/mm/pgtable_64.c +++ b/arch/powerpc/mm/pgtable_64.c @@ -112,7 +112,7 @@ unsigned long ioremap_bot = IOREMAP_BASE; * __ioremap_at - Low level function to establish the page tables * for an IO mapping */ -void __iomem *__ioremap_at(phys_addr_t pa, void *ea, unsigned long size, pgprot_t prot) +static void __iomem * hash__ioremap_at(phys_addr_t pa, void *ea, unsigned long size, pgprot_t prot) { unsigned long i; @@ -120,6 +120,50 @@ void __iomem *__ioremap_at(phys_addr_t pa, void *ea, unsigned long size, pgprot_ if (pgprot_val(prot) & H_PAGE_4K_PFN) return NULL; + for (i = 0; i < size; i += PAGE_SIZE) + if (map_kernel_page((unsigned long)ea + i, pa + i, prot)) + return NULL; + + return (void __iomem *)ea; +} + +static int radix__ioremap_page_range(unsigned long addr, unsigned long end, + phys_addr_t phys_addr, pgprot_t prot) +{ + while (addr != end) { + if (!(addr & ~PUD_MASK) && !(phys_addr & ~PUD_MASK) && + end - addr >= PUD_SIZE) { + if (radix__map_kernel_page(addr, phys_addr, prot, PUD_SIZE)) + return -ENOMEM; + addr += PUD_SIZE; + phys_addr += PUD_SIZE; + + } else if (!(addr & ~PMD_MASK) && !(phys_addr & ~PMD_MASK) && + end - addr >= PMD_SIZE) { + if (radix__map_kernel_page(addr, phys_addr, prot, PMD_SIZE)) + return -ENOMEM; + addr += PMD_SIZE; + phys_addr += PMD_SIZE; + + } else { + if (radix__map_kernel_page(addr, phys_addr, prot, PAGE_SIZE)) + return -ENOMEM; + addr += PAGE_SIZE; + phys_addr += PAGE_SIZE; + } + } + return 0; +} + +static void __iomem * radix__ioremap_at(phys_addr_t pa, void *ea, unsigned long size, pgprot_t prot) +{ + if (radix__ioremap_page_range((unsigned long)ea, (unsigned long)ea + size, pa, prot)) + return NULL; + return ea; +} + +void __iomem *__ioremap_at(phys_addr_t pa, void *ea, unsigned long size, pgprot_t prot) +{ if ((ea + size) >= (void *)IOREMAP_END) { pr_warn("Outside the supported range\n"); return NULL; @@ -129,11 +173,9 @@ void __iomem *__ioremap_at(phys_addr_t pa, void *ea, unsigned long size, pgprot_ WARN_ON(((unsigned long)ea) & ~PAGE_MASK); WARN_ON(size & ~PAGE_MASK); - for (i = 0; i < size; i += PAGE_SIZE) - if (map_kernel_page((unsigned long)ea + i, pa + i, prot)) - return NULL; - - return (void __iomem *)ea; + if (radix_enabled()) + return radix__ioremap_at(pa, ea, size, prot); + return hash__ioremap_at(pa, ea, size, prot); } /**