From patchwork Tue May 28 12:04:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 10964807 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 B9407112C for ; Tue, 28 May 2019 12:08:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A83AA22B39 for ; Tue, 28 May 2019 12:08:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BF2E28358; Tue, 28 May 2019 12:08:59 +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 408ED28306 for ; Tue, 28 May 2019 12:08:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 19A156B026F; Tue, 28 May 2019 08:08:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 14BFE6B0272; Tue, 28 May 2019 08:08:58 -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 03A756B0273; Tue, 28 May 2019 08:08:57 -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 BD6F66B026F for ; Tue, 28 May 2019 08:08:57 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id d22so5958964plr.0 for ; Tue, 28 May 2019 05:08:57 -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=eTusNcynv/bdHJGyOGAguPJgIGBXkK8mZssjLj2XyYA=; b=JcLwILsZTLHj2mnaC8wiWHloURpnNKavoJjhMWOX0pv0H3GbKNDM9h4CX5YtRrtAXh JuZy3ApuwK4SHl4LdHH6aQVrZCwQ+KUXMJGXrMbFxgVr9DIv+nVkPxB0g1kYAjpvfvJ/ EAKrF9xw110WdOHmWQ7K5tO85IjQJzKOdVEkB0WB7cAXXDsVhaiKZyLQsIYsz7J8qyug F0EiGBZAfE5Po8khFFsHyGEXbdGC0+mCySqc0HWpWeV3ZaPgSHMahdg2jrgtiIhi5ltp Qajp3K7znG2eVG5bx8IIIieOqjywQKtECuQyaWKw7slHDcZz70fYeSq76EPp1tVJVhbD OGuA== X-Gm-Message-State: APjAAAVQOnXHFGPIWSFjl8XEwwzEgf0k8GlmBlJ+/Xp8kzfB9QHt+Jlc aL45l8iHOJi6tiTocY/n/YdkCVtH9PkMnUksTKQSteZOAF8CInRSRQWCUDR/gyYCvmsnjiUZ5DT 2NbGgIstat23kBXFq1QVhkKwAPYMpdovJWtUDF24Vr7fsLdwNMe4y3pY5P2i19toViA== X-Received: by 2002:a63:4621:: with SMTP id t33mr131670323pga.246.1559045337305; Tue, 28 May 2019 05:08:57 -0700 (PDT) X-Received: by 2002:a63:4621:: with SMTP id t33mr131670232pga.246.1559045336571; Tue, 28 May 2019 05:08:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559045336; cv=none; d=google.com; s=arc-20160816; b=Z/QtoO0egxaM4oYPNuKGZ8rYcY72Ihky+XiNhhayAT7Tc4ihBmeK4FUvRmXu3Hw1ji K1JxOhO5AW9F2vte4LGSFa1fd8UP+JuF8wlc6G0f7YdGLnZA2DCmUcc0y1uWLTtlu5IA x1vLmGV0lTI/kEDSE87VwIfavonoOCIDuqB7+st88L1Hb0HF9B30I4Flr2t0OOZr8OAF gRmBheqcWlHJWYqxj07AcWyXdWqsGL1av1n+sn94za10VDTPPKOqtFoVSSK0OzsJmMZ8 ZB4YhEqs3A+HZ8Vz5D1KzQPMGrKdfMJeVBos4ZjzYaiKlnFHkr00rmic9yXel7Kki9K8 vflg== 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=eTusNcynv/bdHJGyOGAguPJgIGBXkK8mZssjLj2XyYA=; b=gItL5JO7syJfH0H+2sN0nQI0PmTShoqx3Ju3ACyF0EpYmKPHFNfYRbAt0z0+UFUZO1 vqJVRi9bHKC9blaFOReiNHJ4i7EXo64Bn3FTX3RuZtKZih4rrsyd8AAqoFwnECHJtALE TXY50xi6ieGKP+hqe3iuuWJUKG/q75YAUfkc6kcHR9+WzlZ2txY8TC54P6JLsEOIzIfN D/VPQR+5eusTjmVmIDxEYHMDqH9Xjh/mjOTg0P8EnGvmQ8HJWY4jaeoab6ZG+65LtF1A ogBWg4RtLEvLyYVubWjNm+Jpq/V2F/U0Whjb6Gew+fIJXF99sPjKVCDWfwcVbJbFbuFR vFvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gePFim6z; 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 185sor14183486pfe.20.2019.05.28.05.08.56 for (Google Transport Security); Tue, 28 May 2019 05:08:56 -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=gePFim6z; 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=eTusNcynv/bdHJGyOGAguPJgIGBXkK8mZssjLj2XyYA=; b=gePFim6zy/Px8intSzG3g1lUm9vIEviqyResVqM6CMdmkHMLPZyzYcfuwwNOxWJfyT PrAf+88EhsQYxRofAWQhwIpvu02BtlRxH6B7y9bPp7IW4+Pw9hlXglaG+/T1Rl7dEf2c Ig3Z4yWui4X8BvFJKwhblZtN94P9o9ze/YWo3gZ4Y/oLOWaOth0PPKAWRL02FmRw+ZhO eCyYQZ5uc/WVq9pca8eZV/pt/jB5V+O/cby5U0eP2B94eRM+PQasAlPHQZ/0QI2iJOch MXkQGbR47WKp7efgV3Z9hfcGZr2aRt3ImGKBmxlbUwF+NHv7L3aSaV9JLouvyVVxraO8 wbxQ== X-Google-Smtp-Source: APXvYqxouyX+FBCZ+/B4VzV3O/6LZwxnEZp2c8WyrjNaNIPzurMIp7er5TLrN3wxXTQP4ciUsmcvow== X-Received: by 2002:a62:38d8:: with SMTP id f207mr82932613pfa.131.1559045334758; Tue, 28 May 2019 05:08:54 -0700 (PDT) Received: from bobo.local0.net (193-116-79-40.tpgi.com.au. [193.116.79.40]) by smtp.gmail.com with ESMTPSA id d15sm37463327pfm.186.2019.05.28.05.08.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 May 2019 05:08:53 -0700 (PDT) From: Nicholas Piggin To: linux-mm@kvack.org Cc: Nicholas Piggin , linux-arch@vger.kernel.org, Toshi Kani , Linus Torvalds , Ard Biesheuvel , Andrew Morton , Uladzislau Rezki Subject: [PATCH 1/4] mm/large system hash: use vmalloc for size > MAX_ORDER when !hashdist Date: Tue, 28 May 2019 22:04:50 +1000 Message-Id: <20190528120453.27374-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 limiting system hash sizes. 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 d66bc8abe0af..dd419a074141 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -8029,7 +8029,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 { /* @@ -8037,10 +8037,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 Tue May 28 12:04:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 10964809 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 B3E4E76 for ; Tue, 28 May 2019 12:09:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3A9822B39 for ; Tue, 28 May 2019 12:09:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 973FD28358; Tue, 28 May 2019 12:09:02 +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 3C37122B39 for ; Tue, 28 May 2019 12:09:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F07596B0272; Tue, 28 May 2019 08:09:00 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EBC376B0273; Tue, 28 May 2019 08:09:00 -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 DA7816B0274; Tue, 28 May 2019 08:09:00 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id A3A426B0272 for ; Tue, 28 May 2019 08:09:00 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id 63so13839812pga.18 for ; Tue, 28 May 2019 05:09:00 -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=ebFdeU/x57ZdMACMC1qwFSZewCnBUbRvAij1iV66B8w=; b=WSg72844m9wJmE/xHAcVTzYLkArINR2Sj/bi+kp0tPkDG1GayRhJVeLkqG+ulQ8GtS t4Yd5taeg1m/9DhrXWIv0KDSWZNjZu3tGEkmtO4CJfl1y6vn4k6PbMyCCcGjYlZcQJ/N QDNDWAkoTHQW9bD0pq9fPY9YVD+zBCaFMOs4aI65F7OxWZtmQXsV0uKWLTrHkGgRw5yX Im84/dFq9GMvAZo0tDs872wDF/H+nr5VVpm4cO5/aJL3gS32KoaSKNgPfF5H4JcZHM49 RV0a5eME9NvpGJ9dyMvLwUIITAS2a7+6c9aOHP/SRU/6Tdjqp/+9MorNdy+hKzfJqcfy 4JEQ== X-Gm-Message-State: APjAAAUuHnPojJH421vxG6lHBvVvVojY+RDx7s6SpyYwJuPVCyQf1W5W UVioXBaMp6a3fCb4eA5gDGQLAXPsiOjcsi4ozitLRy5EpJQThnDV5rxp2B4EefxFuBmJ9pwy3Iz AanjwCBfqaUVNo1mldiBoZAtDWMX+rITg7oAqUIfL18qUTZOBkFuch4kydIbq0dbBHg== X-Received: by 2002:a63:9dc8:: with SMTP id i191mr130702127pgd.91.1559045340218; Tue, 28 May 2019 05:09:00 -0700 (PDT) X-Received: by 2002:a63:9dc8:: with SMTP id i191mr130702030pgd.91.1559045339377; Tue, 28 May 2019 05:08:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559045339; cv=none; d=google.com; s=arc-20160816; b=sugCMsy9cR6aI4ALUX9a3nOdr5dO2LGZjNhJcCqYQkGQB7ktgqSvrQ8d6vQGnVKhE4 sCEjq6ErTw0kU/m1gjHlN3bDJODX8VUxZ7eiU45wrU5CnD2Ac+aNmYJZqf6sZRVW7mB8 ufcifTPuJOgKm7rM+LloWgFiD1JucxAz8iKjnOlVfMtc9S1RjUDfqFmYBnCEAJMi2OR0 fRJ+WOdOTiyYdhq2UPGNudHDnWAe+qXrrkVYtiFG1GAqeh+dLXOpP1N4QEzdItk8PKcH BR5rpJO720ZrxkYCQbCv7W8TVTbubf+hZt5TO7xkUBSLLhYgBwMPFYjZMBEcoj8Kb9K7 vXAA== 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=ebFdeU/x57ZdMACMC1qwFSZewCnBUbRvAij1iV66B8w=; b=AaxxOJi++HXTDwCIegfSaxo8JglSSFFbEPECsI7/IjS6JxW4NaSP0KugNLKuvQHee+ RGzE3sjdnjYKaF8ycTpbJwNAnxdKN1j35Pp2aBIMCdnYL7/otAkMVyWwCWH8Id+YuQr/ MpYK1dnAHzEX349kLP2uOnWMve0H1DapERdW5XWeMG2lCpSc/f4Cmpvz0TNfdhPQXPiC 3dq5OXO2WHtC0rbLLZc233k/ZheiS9Gm8K7hO1GZVTchgSPFsrTsw9S8MMJmas7d5woD 5k2D5ti9ZDaIFQHDfFQxgboiWQLnaYqtOatujV8nS8gh7uA2+MYhizfKHX6zjY7q7G0+ Vhxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rzjb4ij1; 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 q31sor2575335pgm.26.2019.05.28.05.08.59 for (Google Transport Security); Tue, 28 May 2019 05:08:59 -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=rzjb4ij1; 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=ebFdeU/x57ZdMACMC1qwFSZewCnBUbRvAij1iV66B8w=; b=rzjb4ij10+/XxoGw4xo1USbcEjpbBtBE67CAkFvaT9rnRvwjnReaCSNwGBTafidpDd N2KAZFQmrx3PSfEKRlrzktw3gmIH2OmNKm0hzSG9LR5hM4Eo2CbGrIT8u0BJh/qQBmZR QTDWfDr+Ze3TiRRx/z9qozasTMLZECBVBvKtz3g9LsN14GkjdFgbcSwqBPrnbWSFdk4z YLILvXkBDdmuFtLGN8yh1V+5gfjBWhFxxxJQ96oOe3WwUrH8xJ4cOCm3K7SmegRz/WJm NwPVC/RjxwaMlySFNSNpGXbpE496iOnPSzMUcVJ/ZHkVFLCYpebb8OAaA+R92Of82ReU CuNg== X-Google-Smtp-Source: APXvYqxWlHJ6CGIXx8iWA545z8hn9HZiC2rBd/N0Q5OS/i01zrRYILt795J+oHF1Ho4PVBFyoRgN2g== X-Received: by 2002:a63:ee0b:: with SMTP id e11mr80785802pgi.453.1559045339023; Tue, 28 May 2019 05:08:59 -0700 (PDT) Received: from bobo.local0.net (193-116-79-40.tpgi.com.au. [193.116.79.40]) by smtp.gmail.com with ESMTPSA id d15sm37463327pfm.186.2019.05.28.05.08.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 May 2019 05:08:58 -0700 (PDT) From: Nicholas Piggin To: linux-mm@kvack.org Cc: Nicholas Piggin , linux-arch@vger.kernel.org, Toshi Kani , Linus Torvalds , Ard Biesheuvel , Andrew Morton , Uladzislau Rezki Subject: [PATCH 2/4] mm/large system hash: avoid vmap for non-NUMA machines when hashdist Date: Tue, 28 May 2019 22:04:51 +1000 Message-Id: <20190528120453.27374-2-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190528120453.27374-1-npiggin@gmail.com> References: <20190528120453.27374-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 dd419a074141..15478dba1144 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -8029,7 +8029,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 Tue May 28 12:04:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 10964811 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 8D77776 for ; Tue, 28 May 2019 12:09:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BCA422B39 for ; Tue, 28 May 2019 12:09:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F52228358; Tue, 28 May 2019 12:09:09 +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 320AC22B39 for ; Tue, 28 May 2019 12:09:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 014726B0275; Tue, 28 May 2019 08:09:07 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F05996B0276; Tue, 28 May 2019 08:09:06 -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 D7F696B0278; Tue, 28 May 2019 08:09:06 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id 98B956B0275 for ; Tue, 28 May 2019 08:09:06 -0400 (EDT) Received: by mail-pg1-f197.google.com with SMTP id g38so13829637pgl.22 for ; Tue, 28 May 2019 05:09:06 -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=rpHM44yAAw//wR+baLC6z16WVts2B8ElzhqciMxNN6c=; b=jEIlw+J2ohBTa6SqAHrJaAn+9Xm72oHn/ZcYSE/QYI3m2xlMbd/3zn7iSzPrOt9Uo0 5mToF9elUb3n0+AaVKyfeSJJLsVaEvxL4Tc8msO37rMjjzfXZk1Ab9YrRPtu/NfUG94e E+JQQTfgiW4VR/W7SM/rjUc+6XLslur9VdVNj3dQsui+30Dkh52ZS/n0N21fbNcdM/ZW pcd0HO2JNsmgNzX8DM588gvyhTCgXkFbQCVeNZNBan9UTG9HPDzDPoTVuoBu36Xkmeo9 ztPF08M6dv/lr+QV84coyYTu0V/BGyu4GgbxlXwngnuLzG2fd27mKeR0bXkURQvq63r1 OWgg== X-Gm-Message-State: APjAAAWNSCedtuB+Y3YRWbm4V4Z4tCBUIYmphkXJCm20DEIpb6/gVG8n 4Tob3jazsUG191VQ186hUhrGF6LsCwWxAhsywxXmUaforoqOqNGgb0u6BygqbzD8gelPV14e1bz MkQkiMqC/CD0F7TJ7romQ/W1M6EokFg9lZDWm5Qws4DU6WQ7gu9Wp+FegofrTX7cqHA== X-Received: by 2002:a17:90a:718c:: with SMTP id i12mr5574424pjk.32.1559045346216; Tue, 28 May 2019 05:09:06 -0700 (PDT) X-Received: by 2002:a17:90a:718c:: with SMTP id i12mr5574210pjk.32.1559045344552; Tue, 28 May 2019 05:09:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559045344; cv=none; d=google.com; s=arc-20160816; b=D/sg8rSW4RkGxUVwtatvKLPqz9Hr3LxpJrcKm3hl2SaXj5wE8IkcqtUB4YN/TiO11V uJixnO2bCDs6noQ6qySzQs7+gAkVflu/CYU/VThhYWZYIM47y9xVK1oOztOAkL7+hj6h uQ8Sqz6y2HOaYpjcrfSoN99ttuWTjkt93FUXgfWwPEfh27ybZtK8zJZOlkDEJ/o+lwQ5 w2/SHM0UpxOUrxEDwi/rko/OAFGdaa/vxhZkGcJdVWbq724Bs9eulw039AwQdyXtTcJr MrcnGpe9R7rUgTGripSz15Ec5qhRHY3Kvjc9+z7z/opLG76lpOn1GfxEflpEq/1GkLU8 jbkA== 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=rpHM44yAAw//wR+baLC6z16WVts2B8ElzhqciMxNN6c=; b=vucd1oMrgh/hS0o3BsF1QEaIuLuPHwYsub+aCfZ9ROnrMjDSzUVonPzEaWbHdJli5x otiASEmzi0lH1AvfNlrRNPSh0o17I+cV1jNaHlqHWVrIv7zocAj24VZrNEHDn5U8e+MU 9uhrWaUt0ECLrHdpHLS0T+FbtL5b65g5JZLeN9EteaCphkT9cFoQ3MuIe+UtYdKZcNoy RKRwP8LS1OgDFKYzRhDrazgyFYzBO5qSZUFArisNz8T7cTLn1fu5vWs4Rgm5qNNg1dEA icyEmxuHGrumKg+klz7rwoLQ94Ld38mdrWFUKX3HTAmfVpXyxeM87tmgdZObofvoXoT1 HaFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GkKo1YDR; 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 gn3sor7320041plb.55.2019.05.28.05.09.04 for (Google Transport Security); Tue, 28 May 2019 05:09:04 -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=GkKo1YDR; 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=rpHM44yAAw//wR+baLC6z16WVts2B8ElzhqciMxNN6c=; b=GkKo1YDRNKtYKY53hbho1Vvc/EOX7aIrv3cliFCXDZmVXXH0Frwwq8zxOX6r6LWoVx MRM8548vQWdBvehje9/JJ4HtPp6R8ym6TBk3C9aM5QVa9va1a3uugRIQ1zhIYPdWGAGe GfQSEGhjJL2R501pdsUdNTw2ylfPoMsXTkvmG64g1tnUxSuZZgQbkt/Efxk1ImbChaiO 9lZTr9JxRH9MKsUrk3kuN0uHarpSopL5g3l7mxMup67O3kQiylhmw6V50bFMy2783Yu8 G4EHS2Zp+rGQWDLvkYkCb2dGHhA4ReWBd/T+2ObQtE/ll7gBW5/DRnVUetUZWUIzMQ+s Ddjg== X-Google-Smtp-Source: APXvYqwovI6TUCqZvBm95UUExXviSf2mOJ5mk3uaFqn6Critn1yRGeSUyaPe4p3MPksHxo9arWX+Uw== X-Received: by 2002:a17:902:404:: with SMTP id 4mr42254710ple.204.1559045343753; Tue, 28 May 2019 05:09:03 -0700 (PDT) Received: from bobo.local0.net (193-116-79-40.tpgi.com.au. [193.116.79.40]) by smtp.gmail.com with ESMTPSA id d15sm37463327pfm.186.2019.05.28.05.08.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 May 2019 05:09:03 -0700 (PDT) From: Nicholas Piggin To: linux-mm@kvack.org Cc: Nicholas Piggin , linux-arch@vger.kernel.org, Toshi Kani , Linus Torvalds , Ard Biesheuvel , Andrew Morton , Uladzislau Rezki Subject: [PATCH 3/4] mm: Move ioremap page table mapping function to mm/ Date: Tue, 28 May 2019 22:04:52 +1000 Message-Id: <20190528120453.27374-3-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190528120453.27374-1-npiggin@gmail.com> References: <20190528120453.27374-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 ioremap_page_range is a useful generic function to create a kernel virtual mapping, move it to mm/vmalloc.c and rename it vmap_range to be used by a subsequent change. For clarity with this move, also: - Rename vunmap_page_range (vmap_range's inverse) to vunmap_range. - Rename vmap_page_range (which takes a page array) to vmap_pages. Signed-off-by: Nicholas Piggin --- include/linux/vmalloc.h | 3 + lib/ioremap.c | 173 +++--------------------------- mm/vmalloc.c | 227 ++++++++++++++++++++++++++++++++++++---- 3 files changed, 228 insertions(+), 175 deletions(-) diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index 51e131245379..812bea5866d6 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -147,6 +147,9 @@ extern struct vm_struct *find_vm_area(const void *addr); extern int map_vm_area(struct vm_struct *area, pgprot_t prot, struct page **pages); #ifdef CONFIG_MMU +extern int vmap_range(unsigned long addr, + unsigned long end, phys_addr_t phys_addr, pgprot_t prot, + unsigned int max_page_shift); extern int map_kernel_range_noflush(unsigned long start, unsigned long size, pgprot_t prot, struct page **pages); extern void unmap_kernel_range_noflush(unsigned long addr, unsigned long size); diff --git a/lib/ioremap.c b/lib/ioremap.c index 063213685563..e13946da8ec3 100644 --- a/lib/ioremap.c +++ b/lib/ioremap.c @@ -58,165 +58,24 @@ static inline int ioremap_pud_enabled(void) { return 0; } static inline int ioremap_pmd_enabled(void) { return 0; } #endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */ -static int ioremap_pte_range(pmd_t *pmd, unsigned long addr, - unsigned long end, phys_addr_t phys_addr, pgprot_t prot) -{ - pte_t *pte; - u64 pfn; - - pfn = phys_addr >> PAGE_SHIFT; - pte = pte_alloc_kernel(pmd, addr); - if (!pte) - return -ENOMEM; - do { - BUG_ON(!pte_none(*pte)); - set_pte_at(&init_mm, addr, pte, pfn_pte(pfn, prot)); - pfn++; - } while (pte++, addr += PAGE_SIZE, addr != end); - return 0; -} - -static int ioremap_try_huge_pmd(pmd_t *pmd, unsigned long addr, - unsigned long end, phys_addr_t phys_addr, - pgprot_t prot) -{ - if (!ioremap_pmd_enabled()) - return 0; - - if ((end - addr) != PMD_SIZE) - return 0; - - if (!IS_ALIGNED(phys_addr, PMD_SIZE)) - return 0; - - if (pmd_present(*pmd) && !pmd_free_pte_page(pmd, addr)) - return 0; - - return pmd_set_huge(pmd, phys_addr, prot); -} - -static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr, - unsigned long end, phys_addr_t phys_addr, pgprot_t prot) -{ - pmd_t *pmd; - unsigned long next; - - pmd = pmd_alloc(&init_mm, pud, addr); - if (!pmd) - return -ENOMEM; - do { - next = pmd_addr_end(addr, end); - - if (ioremap_try_huge_pmd(pmd, addr, next, phys_addr, prot)) - continue; - - if (ioremap_pte_range(pmd, addr, next, phys_addr, prot)) - return -ENOMEM; - } while (pmd++, phys_addr += (next - addr), addr = next, addr != end); - return 0; -} - -static int ioremap_try_huge_pud(pud_t *pud, unsigned long addr, - unsigned long end, phys_addr_t phys_addr, - pgprot_t prot) -{ - if (!ioremap_pud_enabled()) - return 0; - - if ((end - addr) != PUD_SIZE) - return 0; - - if (!IS_ALIGNED(phys_addr, PUD_SIZE)) - return 0; - - if (pud_present(*pud) && !pud_free_pmd_page(pud, addr)) - return 0; - - return pud_set_huge(pud, phys_addr, prot); -} - -static inline int ioremap_pud_range(p4d_t *p4d, unsigned long addr, - unsigned long end, phys_addr_t phys_addr, pgprot_t prot) -{ - pud_t *pud; - unsigned long next; - - pud = pud_alloc(&init_mm, p4d, addr); - if (!pud) - return -ENOMEM; - do { - next = pud_addr_end(addr, end); - - if (ioremap_try_huge_pud(pud, addr, next, phys_addr, prot)) - continue; - - if (ioremap_pmd_range(pud, addr, next, phys_addr, prot)) - return -ENOMEM; - } while (pud++, phys_addr += (next - addr), addr = next, addr != end); - return 0; -} - -static int ioremap_try_huge_p4d(p4d_t *p4d, unsigned long addr, - unsigned long end, phys_addr_t phys_addr, - pgprot_t prot) -{ - if (!ioremap_p4d_enabled()) - return 0; - - if ((end - addr) != P4D_SIZE) - return 0; - - if (!IS_ALIGNED(phys_addr, P4D_SIZE)) - return 0; - - if (p4d_present(*p4d) && !p4d_free_pud_page(p4d, addr)) - return 0; - - return p4d_set_huge(p4d, phys_addr, prot); -} - -static inline int ioremap_p4d_range(pgd_t *pgd, unsigned long addr, - unsigned long end, phys_addr_t phys_addr, pgprot_t prot) -{ - p4d_t *p4d; - unsigned long next; - - p4d = p4d_alloc(&init_mm, pgd, addr); - if (!p4d) - return -ENOMEM; - do { - next = p4d_addr_end(addr, end); - - if (ioremap_try_huge_p4d(p4d, addr, next, phys_addr, prot)) - continue; - - if (ioremap_pud_range(p4d, addr, next, phys_addr, prot)) - return -ENOMEM; - } while (p4d++, phys_addr += (next - addr), addr = next, addr != end); - return 0; -} - int ioremap_page_range(unsigned long addr, unsigned long end, phys_addr_t phys_addr, pgprot_t prot) { - pgd_t *pgd; - unsigned long start; - unsigned long next; - int err; - - might_sleep(); - BUG_ON(addr >= end); - - start = addr; - pgd = pgd_offset_k(addr); - do { - next = pgd_addr_end(addr, end); - err = ioremap_p4d_range(pgd, addr, next, phys_addr, prot); - if (err) - break; - } while (pgd++, phys_addr += (next - addr), addr = next, addr != end); - - flush_cache_vmap(start, end); + unsigned int max_page_shift = PAGE_SHIFT; + + /* + * Due to the max_page_shift parameter to vmap_range, platforms must + * enable all smaller sizes to take advantage of a given size, + * otherwise fall back to small pages. + */ + if (ioremap_pmd_enabled()) { + max_page_shift = PMD_SHIFT; + if (ioremap_pud_enabled()) { + max_page_shift = PUD_SHIFT; + if (ioremap_p4d_enabled()) + max_page_shift = P4D_SHIFT; + } + } - return err; + return vmap_range(addr, end, phys_addr, prot, max_page_shift); } diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 233af6936c93..6a0c97f89091 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -119,7 +119,7 @@ static void vunmap_p4d_range(pgd_t *pgd, unsigned long addr, unsigned long end) } while (p4d++, addr = next, addr != end); } -static void vunmap_page_range(unsigned long addr, unsigned long end) +static void vunmap_range(unsigned long addr, unsigned long end) { pgd_t *pgd; unsigned long next; @@ -135,6 +135,197 @@ static void vunmap_page_range(unsigned long addr, unsigned long end) } static int vmap_pte_range(pmd_t *pmd, unsigned long addr, + unsigned long end, phys_addr_t phys_addr, pgprot_t prot) +{ + pte_t *pte; + u64 pfn; + + pfn = phys_addr >> PAGE_SHIFT; + pte = pte_alloc_kernel(pmd, addr); + if (!pte) + return -ENOMEM; + do { + BUG_ON(!pte_none(*pte)); + set_pte_at(&init_mm, addr, pte, pfn_pte(pfn, prot)); + pfn++; + } while (pte++, addr += PAGE_SIZE, addr != end); + return 0; +} + +static int vmap_try_huge_pmd(pmd_t *pmd, unsigned long addr, + unsigned long end, phys_addr_t phys_addr, pgprot_t prot, + unsigned int max_page_shift) +{ + if (!IS_ENABLED(CONFIG_HAVE_ARCH_HUGE_VMAP)) + return 0; + + if (max_page_shift < PMD_SIZE) + return 0; + + if ((end - addr) != PMD_SIZE) + return 0; + + if (!IS_ALIGNED(phys_addr, PMD_SIZE)) + return 0; + + if (pmd_present(*pmd) && !pmd_free_pte_page(pmd, addr)) + return 0; + + return pmd_set_huge(pmd, phys_addr, prot); +} + +static inline int vmap_pmd_range(pud_t *pud, unsigned long addr, + unsigned long end, phys_addr_t phys_addr, pgprot_t prot, + unsigned int max_page_shift) +{ + pmd_t *pmd; + unsigned long next; + + pmd = pmd_alloc(&init_mm, pud, addr); + if (!pmd) + return -ENOMEM; + do { + next = pmd_addr_end(addr, end); + + if (vmap_try_huge_pmd(pmd, addr, next, phys_addr, prot, + max_page_shift)) + continue; + + if (vmap_pte_range(pmd, addr, next, phys_addr, prot)) + return -ENOMEM; + } while (pmd++, phys_addr += (next - addr), addr = next, addr != end); + return 0; +} + +static int vmap_try_huge_pud(pud_t *pud, unsigned long addr, + unsigned long end, phys_addr_t phys_addr, pgprot_t prot, + unsigned int max_page_shift) +{ + if (!IS_ENABLED(CONFIG_HAVE_ARCH_HUGE_VMAP)) + return 0; + + if (max_page_shift < PUD_SIZE) + return 0; + + if ((end - addr) != PUD_SIZE) + return 0; + + if (!IS_ALIGNED(phys_addr, PUD_SIZE)) + return 0; + + if (pud_present(*pud) && !pud_free_pmd_page(pud, addr)) + return 0; + + return pud_set_huge(pud, phys_addr, prot); +} + +static inline int vmap_pud_range(p4d_t *p4d, unsigned long addr, + unsigned long end, phys_addr_t phys_addr, pgprot_t prot, + unsigned int max_page_shift) +{ + pud_t *pud; + unsigned long next; + + pud = pud_alloc(&init_mm, p4d, addr); + if (!pud) + return -ENOMEM; + do { + next = pud_addr_end(addr, end); + + if (vmap_try_huge_pud(pud, addr, next, phys_addr, prot, + max_page_shift)) + continue; + + if (vmap_pmd_range(pud, addr, next, phys_addr, prot, + max_page_shift)) + return -ENOMEM; + } while (pud++, phys_addr += (next - addr), addr = next, addr != end); + return 0; +} + +static int vmap_try_huge_p4d(p4d_t *p4d, unsigned long addr, + unsigned long end, phys_addr_t phys_addr, pgprot_t prot, + unsigned int max_page_shift) +{ + if (!IS_ENABLED(CONFIG_HAVE_ARCH_HUGE_VMAP)) + return 0; + + if (max_page_shift < P4D_SIZE) + return 0; + + if ((end - addr) != P4D_SIZE) + return 0; + + if (!IS_ALIGNED(phys_addr, P4D_SIZE)) + return 0; + + if (p4d_present(*p4d) && !p4d_free_pud_page(p4d, addr)) + return 0; + + return p4d_set_huge(p4d, phys_addr, prot); +} + +static inline int vmap_p4d_range(pgd_t *pgd, unsigned long addr, + unsigned long end, phys_addr_t phys_addr, pgprot_t prot, + unsigned int max_page_shift) +{ + p4d_t *p4d; + unsigned long next; + + p4d = p4d_alloc(&init_mm, pgd, addr); + if (!p4d) + return -ENOMEM; + do { + next = p4d_addr_end(addr, end); + + if (vmap_try_huge_p4d(p4d, addr, next, phys_addr, prot, + max_page_shift)) + continue; + + if (vmap_pud_range(p4d, addr, next, phys_addr, prot, + max_page_shift)) + return -ENOMEM; + } while (p4d++, phys_addr += (next - addr), addr = next, addr != end); + return 0; +} + +static int vmap_range_noflush(unsigned long addr, + unsigned long end, phys_addr_t phys_addr, pgprot_t prot, + unsigned int max_page_shift) +{ + pgd_t *pgd; + unsigned long start; + unsigned long next; + int err; + + might_sleep(); + BUG_ON(addr >= end); + + start = addr; + pgd = pgd_offset_k(addr); + do { + next = pgd_addr_end(addr, end); + err = vmap_p4d_range(pgd, addr, next, phys_addr, prot, + max_page_shift); + if (err) + break; + } while (pgd++, phys_addr += (next - addr), addr = next, addr != end); + + return err; +} + +int vmap_range(unsigned long addr, + unsigned long end, phys_addr_t phys_addr, pgprot_t prot, + unsigned int max_page_shift) +{ + int ret; + + ret = vmap_range_noflush(addr, end, phys_addr, prot, max_page_shift); + flush_cache_vmap(start, end); + return ret; +} + +static int vmap_pages_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, pgprot_t prot, struct page **pages, int *nr) { pte_t *pte; @@ -160,7 +351,7 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr, return 0; } -static int vmap_pmd_range(pud_t *pud, unsigned long addr, +static int vmap_pages_pmd_range(pud_t *pud, unsigned long addr, unsigned long end, pgprot_t prot, struct page **pages, int *nr) { pmd_t *pmd; @@ -171,13 +362,13 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr, return -ENOMEM; do { next = pmd_addr_end(addr, end); - if (vmap_pte_range(pmd, addr, next, prot, pages, nr)) + if (vmap_pages_pte_range(pmd, addr, next, prot, pages, nr)) return -ENOMEM; } while (pmd++, addr = next, addr != end); return 0; } -static int vmap_pud_range(p4d_t *p4d, unsigned long addr, +static int vmap_pages_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end, pgprot_t prot, struct page **pages, int *nr) { pud_t *pud; @@ -188,13 +379,13 @@ static int vmap_pud_range(p4d_t *p4d, unsigned long addr, return -ENOMEM; do { next = pud_addr_end(addr, end); - if (vmap_pmd_range(pud, addr, next, prot, pages, nr)) + if (vmap_pages_pmd_range(pud, addr, next, prot, pages, nr)) return -ENOMEM; } while (pud++, addr = next, addr != end); return 0; } -static int vmap_p4d_range(pgd_t *pgd, unsigned long addr, +static int vmap_pages_p4d_range(pgd_t *pgd, unsigned long addr, unsigned long end, pgprot_t prot, struct page **pages, int *nr) { p4d_t *p4d; @@ -205,7 +396,7 @@ static int vmap_p4d_range(pgd_t *pgd, unsigned long addr, return -ENOMEM; do { next = p4d_addr_end(addr, end); - if (vmap_pud_range(p4d, addr, next, prot, pages, nr)) + if (vmap_pages_pud_range(p4d, addr, next, prot, pages, nr)) return -ENOMEM; } while (p4d++, addr = next, addr != end); return 0; @@ -217,7 +408,7 @@ 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, +static int vmap_pages_range_noflush(unsigned long start, unsigned long end, pgprot_t prot, struct page **pages) { pgd_t *pgd; @@ -230,7 +421,7 @@ static int vmap_page_range_noflush(unsigned long start, unsigned long end, pgd = pgd_offset_k(addr); do { next = pgd_addr_end(addr, end); - err = vmap_p4d_range(pgd, addr, next, prot, pages, &nr); + err = vmap_pages_p4d_range(pgd, addr, next, prot, pages, &nr); if (err) return err; } while (pgd++, addr = next, addr != end); @@ -238,12 +429,12 @@ static int vmap_page_range_noflush(unsigned long start, unsigned long end, return nr; } -static int vmap_page_range(unsigned long start, unsigned long end, +static int vmap_pages_range(unsigned long start, unsigned long end, pgprot_t prot, struct page **pages) { int ret; - ret = vmap_page_range_noflush(start, end, prot, pages); + ret = vmap_pages_range_noflush(start, end, prot, pages); flush_cache_vmap(start, end); return ret; } @@ -1148,7 +1339,7 @@ static void free_vmap_area(struct vmap_area *va) */ static void unmap_vmap_area(struct vmap_area *va) { - vunmap_page_range(va->va_start, va->va_end); + vunmap_range(va->va_start, va->va_end); } /* @@ -1586,7 +1777,7 @@ static void vb_free(const void *addr, unsigned long size) rcu_read_unlock(); BUG_ON(!vb); - vunmap_page_range((unsigned long)addr, (unsigned long)addr + size); + vunmap_range((unsigned long)addr, (unsigned long)addr + size); if (debug_pagealloc_enabled()) flush_tlb_kernel_range((unsigned long)addr, @@ -1736,7 +1927,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_pages_range(addr, addr + size, prot, pages) < 0) { vm_unmap_ram(mem, count); return NULL; } @@ -1903,7 +2094,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_pages_range_noflush(addr, addr + size, prot, pages); } /** @@ -1922,7 +2113,7 @@ int map_kernel_range_noflush(unsigned long addr, unsigned long size, */ void unmap_kernel_range_noflush(unsigned long addr, unsigned long size) { - vunmap_page_range(addr, addr + size); + vunmap_range(addr, addr + size); } EXPORT_SYMBOL_GPL(unmap_kernel_range_noflush); @@ -1939,7 +2130,7 @@ void unmap_kernel_range(unsigned long addr, unsigned long size) unsigned long end = addr + size; flush_cache_vunmap(addr, end); - vunmap_page_range(addr, end); + vunmap_range(addr, end); flush_tlb_kernel_range(addr, end); } EXPORT_SYMBOL_GPL(unmap_kernel_range); @@ -1950,7 +2141,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_pages_range(addr, end, prot, pages); return err > 0 ? 0 : err; } From patchwork Tue May 28 12:04:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 10964813 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 F23BC76 for ; Tue, 28 May 2019 12:09:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E163E22B39 for ; Tue, 28 May 2019 12:09:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D358628358; Tue, 28 May 2019 12:09:13 +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 098F122B39 for ; Tue, 28 May 2019 12:09:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5DFE96B0278; Tue, 28 May 2019 08:09:11 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 58FA16B0279; Tue, 28 May 2019 08:09:11 -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 4576D6B027A; Tue, 28 May 2019 08:09:11 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 0A0296B0278 for ; Tue, 28 May 2019 08:09:11 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id d7so13856871pgc.8 for ; Tue, 28 May 2019 05:09:11 -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=pn8fi/WvUvwUzQoGGlsgS4xe4epAAh2bTKX49ROjLQ4=; b=K9qVmigxzYpAOuVkKM2y/lL/RGwZJasb9MwR9ibzqzTomnIY/0xTJ/rmnCHM7OhyGt FNiiN39l89tEtbM8z0M8Lui226ADSnsBrMWwMAiVGDayiBlQ2V1H2TSv1kQv6x8kEYqC nEMKMk+eGMKKKGp9Fdd4jgWiieSksfRkS+fPJ2G9dcUMNHgGuahHdGFfYXxeG1QOiQSv rp7Uq1gJIbncfDcWvFnDrPdfG7zHvwX69N+e0QV+TELRFa2CX18sXkOom4/NcZAOp/25 BeqxquvlCFs5q9lY9egtPCwHOR4+E7ih+Kqp+R7UqHbZ6CMjEC6WYJkZcRJ/AbvNRL4X ol4Q== X-Gm-Message-State: APjAAAUu9HTYpTVDfFpJh2RBp1zWrehhF53NHr5V9NKK3IuyW3cDb6p/ ifHelgv8WFGepbdXQevZdBilbTF2SdYLrK6h6m+LDp/+sO8cCcTVzYMdjZhCIPxibAfz+U0mL3Z nddYhbvds+QRyNEW83hO0ohGO5EaWdMx+MutCYl9Rk/Kt1rPC3TKtbGFxFSsPyVwJiQ== X-Received: by 2002:a17:90a:ac18:: with SMTP id o24mr5644884pjq.116.1559045350669; Tue, 28 May 2019 05:09:10 -0700 (PDT) X-Received: by 2002:a17:90a:ac18:: with SMTP id o24mr5644679pjq.116.1559045349125; Tue, 28 May 2019 05:09:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559045349; cv=none; d=google.com; s=arc-20160816; b=SLmEQDkKGbMkmrCVOpQYz5lM9lQxEwbHD3joN0RoUPm7z+c81fqThVn7dim6tTeJMN ctSosLorGadJ2yV7wwaFgTiwUR7Pu43sfByz2epcjiqNedVBZr1BTZ8smRo86bOxluEN I9ZwXbEp0FtFtztOlMKDPf+15VjI60On5Vxtfk51IFTC/YVT6hA4Wrc4zzuCuOkerjUB ttghvOOkNE2n+tDep3hE2lGb7niUkoZ03xA8uNI4D9OHI/a+J2IU/qKrCXqQKEk7q7SK g2g3gednM8GG+Bqo5Gnm6rAU42FULmjO5bmc+WTeVedGAzWTKTYYHZpWuBXcXh78cFY4 E/xw== 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=pn8fi/WvUvwUzQoGGlsgS4xe4epAAh2bTKX49ROjLQ4=; b=pdfoy4UpK2LIk5tO0H1gmBIsuvtmoGkIAqA8R2GEObD64R+Nq9izWnr4sS4Xt9mxi9 B6tfhuDJxSEPQGXrLwyf8fMUIVMrDEi97QjXekym/W9rOjszlcCWMsbWhCokl1dQDwGF 7wG7w9y5NzwLcb/KxIQ1Tz8S9JQjVOWeYgw97mm9Eg6p63TDNWRDagsMTAG7Yzh2C6et k/HMLddLMDDxKUxO10aPbbOVaHT5/0FSkr2by9IGuEh/9ZOpDCTDKd7CybT0rrXaqNTx 9uB8/rwlmc7tRjqIXc/sBWGtLO349FjNLpJ4CRh6W0MMwSUgB7MtGY9tOK1zh4BDJRM/ 2TJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kQuK0GsL; 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 g9sor2850006pjs.21.2019.05.28.05.09.09 for (Google Transport Security); Tue, 28 May 2019 05:09:09 -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=kQuK0GsL; 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=pn8fi/WvUvwUzQoGGlsgS4xe4epAAh2bTKX49ROjLQ4=; b=kQuK0GsL2qZ3B7V5vIm06V1Vk0l7UnVYud20vsF5lcp2Y8Ko/hWCUnMXgVg+sFXR45 vhrHZIstmTyxX7S4xovwvpwYnRbDNAX+IKF8bdjLXMwxn3+FLbHl5/JWxVfD9gbgwZSW JEHBsv5SI1oQOHu01fX8wsCpwWaBaey3gr5KfTfyh8t4h2h0P25agpmKNRGJBp/7S6uQ Jrl+qmsPqe1mcqnr7UocDzuwECcNoLqgLty6y+HXHKTvBVCpkszTiDM93wvxG3dLNUiH dGs6fppKQtGA/LiearoRWYlsuw97Ebr/D1CQULJgTrIXvxeCNgJzrQgjzviHsHhVJYyq kVsA== X-Google-Smtp-Source: APXvYqwW3TeLO4TumFfGqy7Cf/75OHM0IJhVhfngPf1gbu23C7jk4UR4wjogQvLODkbxFfASiCS4tA== X-Received: by 2002:a17:90a:b393:: with SMTP id e19mr5563477pjr.91.1559045348550; Tue, 28 May 2019 05:09:08 -0700 (PDT) Received: from bobo.local0.net (193-116-79-40.tpgi.com.au. [193.116.79.40]) by smtp.gmail.com with ESMTPSA id d15sm37463327pfm.186.2019.05.28.05.09.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 May 2019 05:09:07 -0700 (PDT) From: Nicholas Piggin To: linux-mm@kvack.org Cc: Nicholas Piggin , linux-arch@vger.kernel.org, Toshi Kani , Linus Torvalds , Ard Biesheuvel , Andrew Morton , Uladzislau Rezki Subject: [PATCH 4/4] mm/vmalloc: Hugepage vmalloc mappings Date: Tue, 28 May 2019 22:04:53 +1000 Message-Id: <20190528120453.27374-4-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190528120453.27374-1-npiggin@gmail.com> References: <20190528120453.27374-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 For platforms that define HAVE_ARCH_HUGE_VMAP, have vmalloc try to allocate and map PMD-level huge pages when size is appropriate, and fallback if unsuccessful. Using 2MB page mappings in an 8MB dentry cache hash brings dTLB misses for linux kernel tree `git diff` from 45,000 to 8,000 on a Kaby Lake CPU wth mitigations=off (performance is in the noise, under 1% difference, page tables are likely to be well cached for this workload). Signed-off-by: Nicholas Piggin --- include/linux/vmalloc.h | 1 + mm/vmalloc.c | 132 +++++++++++++++++++++++++++++++--------- 2 files changed, 105 insertions(+), 28 deletions(-) diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index 812bea5866d6..4c92dc608928 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 6a0c97f89091..34de925ed4f4 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -439,6 +440,41 @@ static int vmap_pages_range(unsigned long start, unsigned long end, return ret; } +#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP +static int vmap_hpages_range(unsigned long start, unsigned long end, + pgprot_t prot, struct page **pages, + unsigned int page_shift) +{ + unsigned long addr = start; + unsigned int i, nr = (end - start) >> (PAGE_SHIFT + page_shift); + + for (i = 0; i < nr; i++) { + int err; + + err = vmap_range_noflush(addr, + addr + (PAGE_SIZE << page_shift), + __pa(page_address(pages[i])), prot, + page_shift); + if (err) + return err; + + addr += PAGE_SIZE << page_shift; + } + flush_cache_vmap(start, end); + + return nr; +} +#else +static int vmap_hpages_range(unsigned long start, unsigned long end, + pgprot_t prot, struct page **pages, + unsigned int page_shift) +{ + BUG_ON(page_shift != PAGE_SIZE); + return vmap_pages_range(start, end, prot, pages); +} +#endif + + int is_vmalloc_or_module_addr(const void *x) { /* @@ -461,7 +497,7 @@ struct page *vmalloc_to_page(const void *vmalloc_addr) { unsigned long addr = (unsigned long) vmalloc_addr; struct page *page = NULL; - pgd_t *pgd = pgd_offset_k(addr); + pgd_t *pgd; p4d_t *p4d; pud_t *pud; pmd_t *pmd; @@ -473,27 +509,38 @@ struct page *vmalloc_to_page(const void *vmalloc_addr) */ VIRTUAL_BUG_ON(!is_vmalloc_or_module_addr(vmalloc_addr)); + pgd = pgd_offset_k(addr); if (pgd_none(*pgd)) return NULL; + p4d = p4d_offset(pgd, addr); if (p4d_none(*p4d)) return NULL; - pud = pud_offset(p4d, addr); +#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP + if (p4d_large(*p4d)) + return p4d_page(*p4d) + ((addr & ~P4D_MASK) >> PAGE_SHIFT); +#endif + if (WARN_ON_ONCE(p4d_bad(*p4d))) + return NULL; - /* - * Don't dereference bad PUD or PMD (below) entries. This will also - * identify huge mappings, which we may encounter on architectures - * that define CONFIG_HAVE_ARCH_HUGE_VMAP=y. Such regions will be - * identified as vmalloc addresses by is_vmalloc_addr(), but are - * not [unambiguously] associated with a struct page, so there is - * no correct value to return for them. - */ - WARN_ON_ONCE(pud_bad(*pud)); - if (pud_none(*pud) || pud_bad(*pud)) + pud = pud_offset(p4d, addr); + if (pud_none(*pud)) + return NULL; +#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP + if (pud_large(*pud)) + return pud_page(*pud) + ((addr & ~PUD_MASK) >> PAGE_SHIFT); +#endif + if (WARN_ON_ONCE(pud_bad(*pud))) return NULL; + pmd = pmd_offset(pud, addr); - WARN_ON_ONCE(pmd_bad(*pmd)); - if (pmd_none(*pmd) || pmd_bad(*pmd)) + if (pmd_none(*pmd)) + return NULL; +#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP + if (pmd_large(*pmd)) + return pmd_page(*pmd) + ((addr & ~PMD_MASK) >> PAGE_SHIFT); +#endif + if (WARN_ON_ONCE(pmd_bad(*pmd))) return NULL; ptep = pte_offset_map(pmd, addr); @@ -501,6 +548,7 @@ struct page *vmalloc_to_page(const void *vmalloc_addr) if (pte_present(pte)) page = pte_page(pte); pte_unmap(ptep); + return page; } EXPORT_SYMBOL(vmalloc_to_page); @@ -2184,8 +2232,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)) @@ -2397,7 +2446,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); @@ -2540,14 +2589,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; @@ -2568,10 +2620,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() */ @@ -2583,8 +2633,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_hpages_range(addr, addr + size, prot, pages, page_shift) < 0) goto fail; + return area->addr; fail: @@ -2618,22 +2669,39 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align, pgprot_t prot, unsigned long vm_flags, int node, const void *caller) { - struct vm_struct *area; + struct vm_struct *area = NULL; void *addr; unsigned long real_size = size; + unsigned long real_align = align; + unsigned int shift = PAGE_SHIFT; size = PAGE_ALIGN(size); if (!size || (size >> PAGE_SHIFT) > totalram_pages()) goto fail; + if (IS_ENABLED(CONFIG_HAVE_ARCH_HUGE_VMAP)) { + unsigned long size_per_node; + + size_per_node = size; + if (node == NUMA_NO_NODE) + size_per_node /= num_online_nodes(); + if (size_per_node >= PMD_SIZE) + shift = PMD_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 @@ -2647,8 +2715,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; }