From patchwork Sun May 16 20:20:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 12260589 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 792D1C433ED for ; Sun, 16 May 2021 20:21:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 101A261159 for ; Sun, 16 May 2021 20:21:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 101A261159 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 096EF6B006E; Sun, 16 May 2021 16:21:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 01FB86B0070; Sun, 16 May 2021 16:21:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DDABA6B0071; Sun, 16 May 2021 16:21:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0245.hostedemail.com [216.40.44.245]) by kanga.kvack.org (Postfix) with ESMTP id AB89D6B006E for ; Sun, 16 May 2021 16:21:09 -0400 (EDT) Received: from smtpin36.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 514F36C1D for ; Sun, 16 May 2021 20:21:09 +0000 (UTC) X-FDA: 78148213458.36.CD45B8A Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) by imf22.hostedemail.com (Postfix) with ESMTP id 1B669C0001FA for ; Sun, 16 May 2021 20:21:07 +0000 (UTC) Received: by mail-lf1-f49.google.com with SMTP id j10so5700576lfb.12 for ; Sun, 16 May 2021 13:21:08 -0700 (PDT) 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=LTbrZqzeTIdq/svG2NlB3CMiMALncw0fFJVSdnt0oRk=; b=o78MraK05iBBjWGZuYur/m357uPW50CXSMMUNWrLVGMUFk41oVmfQF5n/osjtwvO25 zIXXjySahdIiA/tYHAuRc7f5BLterfBZ7bf6xVBYSgz3RtZlHjnhEpaV1aWUEEX0oTls 3zrSsOpkeefcocOsYsUWOoOKxbOaAVQkqBSgo4pfIDVoaPkBpvOqNNJimGCFQgrisMFS 2G/jPbk74xoWIure0fmhiMnJdmGWO+pVVr1gyDaUyesuucPIHrwZ3yWbhlrizjAhYJjO o6jaL2V2Ai0EGIYZxx04vXqfEjtnu2tgaW0fPH/oE9MXH328htKhxHybvEePYHK0YCVE uzuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LTbrZqzeTIdq/svG2NlB3CMiMALncw0fFJVSdnt0oRk=; b=R8ZRwBx6Xreb7m06l2uenIZB7pZxsHF3ZZzsiOWOgiFq0nwDMsUVPwlP7DVpNIn1IX Z9GkHT0kKQVqvEjk5iZ7v5GsEy4hKP+9dAcWrWehquQjBFoknIuXqksc58DtXsTUInKF HYnAO2A13y8UH9LNuLSmmNfOKsb3trFoTCBOlRClrYAnVeQhJH8vD0CSi8pqKz/3ZflS ni0/qRdS+Vuz/qc3k/3HfwkvBkN2G4MCJ8dg2TawYqWyI84Bkh0WZ2U/txskSjU49jC/ R1UtuC7SeRjPA3EuXlsbUyhZ0KAoXl7W2er2FeZaiRWoqPd1M43ZKwzw/tz9v0362nWY 8Drg== X-Gm-Message-State: AOAM530yve8M/dUrUGzB8lMi+93Gxl47l3EINdVP46GZLGbpLb/MdjP8 fppIdNxf/8oAQJes3vWsMaA= X-Google-Smtp-Source: ABdhPJyM14gAplAXXpF4AUnSFzgvUSDfbI7eGPa+pyRMtiLmeknUt9gQORE5k1NmjlDrGtmPd4DbrA== X-Received: by 2002:a05:6512:214d:: with SMTP id s13mr39980367lfr.344.1621196467749; Sun, 16 May 2021 13:21:07 -0700 (PDT) Received: from pc638.lan (h5ef52e3d.seluork.dyn.perspektivbredband.net. [94.245.46.61]) by smtp.gmail.com with ESMTPSA id y28sm378195lfg.210.2021.05.16.13.21.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 May 2021 13:21:07 -0700 (PDT) From: "Uladzislau Rezki (Sony)" To: Andrew Morton Cc: linux-mm@kvack.org, LKML , Mel Gorman , Matthew Wilcox , Nicholas Piggin , Uladzislau Rezki , Hillf Danton , Michal Hocko , Oleksiy Avramchenko , Steven Rostedt Subject: [PATCH 1/3] mm/page_alloc: Add an alloc_pages_bulk_array_node() helper Date: Sun, 16 May 2021 22:20:54 +0200 Message-Id: <20210516202056.2120-2-urezki@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210516202056.2120-1-urezki@gmail.com> References: <20210516202056.2120-1-urezki@gmail.com> MIME-Version: 1.0 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=o78MraK0; spf=pass (imf22.hostedemail.com: domain of urezki@gmail.com designates 209.85.167.49 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 1B669C0001FA X-Stat-Signature: bpnmjz4xgfhkykm4a1o4116r8dosweja X-HE-Tag: 1621196467-864220 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: Add a "node" variant of the alloc_pages_bulk_array() function. The helper guarantees that a __alloc_pages_bulk() is invoked with a valid NUMA node ID. Signed-off-by: Uladzislau Rezki (Sony) Acked-by: Mel Gorman --- include/linux/gfp.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 11da8af06704..94f0b8b1cb55 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -536,6 +536,15 @@ alloc_pages_bulk_array(gfp_t gfp, unsigned long nr_pages, struct page **page_arr return __alloc_pages_bulk(gfp, numa_mem_id(), NULL, nr_pages, NULL, page_array); } +static inline unsigned long +alloc_pages_bulk_array_node(gfp_t gfp, int nid, unsigned long nr_pages, struct page **page_array) +{ + if (nid == NUMA_NO_NODE) + nid = numa_mem_id(); + + return __alloc_pages_bulk(gfp, nid, NULL, nr_pages, NULL, page_array); +} + /* * Allocate pages, preferring the node given as nid. The node must be valid and * online. For more general interface, see alloc_pages_node(). From patchwork Sun May 16 20:20:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 12260591 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35A41C433B4 for ; Sun, 16 May 2021 20:21:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CD64761152 for ; Sun, 16 May 2021 20:21:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD64761152 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EEEF36B0070; Sun, 16 May 2021 16:21:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E77626B0071; Sun, 16 May 2021 16:21:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CCB8C6B0072; Sun, 16 May 2021 16:21:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0205.hostedemail.com [216.40.44.205]) by kanga.kvack.org (Postfix) with ESMTP id 9A5856B0070 for ; Sun, 16 May 2021 16:21:10 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 429716C1D for ; Sun, 16 May 2021 20:21:10 +0000 (UTC) X-FDA: 78148213500.12.686D9E4 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) by imf15.hostedemail.com (Postfix) with ESMTP id BB464A00038B for ; Sun, 16 May 2021 20:21:08 +0000 (UTC) Received: by mail-lf1-f48.google.com with SMTP id q7so4398168lfr.6 for ; Sun, 16 May 2021 13:21:09 -0700 (PDT) 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=cF2r85Mr4qUSBfbgYkkNE934MHXCK0CTayY0Q/HL8fs=; b=SuMLTgGZwt/rQoxCVTlgbXsljsshfJPeu32D1fPDttHErdjridjR6B8/gU6r/hYq2S AioVnehGpCcMGOK7f4wC2/25Go62R92MUPUjmcT84qAjW9GM5bXqSmKMJe8MU5MQUO+B C1JsqtSyn/65gLSJnNL2RNxkheklb6hi3UjIMPR/8SywEd+J5Q6+vOkxneOdJPRibnK/ uLi7nsQabeEqwAhzXHvJPbwqbncWKQB/GauWIDbAe+NbF6eQalRdGdUbiLhWm3xj/gVl O8OEWLN7IpY57O06nLimeRFsLbvFplW8vMVSN8594GWs3IlwEYRG+DxcQEfxZELgAwmm 6LRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cF2r85Mr4qUSBfbgYkkNE934MHXCK0CTayY0Q/HL8fs=; b=mHg4IRO0z86hzq9n5w47LfmECV9o31ojgC8lc/1QN8H4CkGX3/E92nwdT64gPNFY7p EhMcoC2EA7VBNh2Rv1v2Dnutgj1XwhkUF26DoeNavSJ6D+tAK4EXmU5Z+NSvkjvtaWD2 u3IGMPriWHQz5x4cM/T36dWOCL5QWEvceZtCeDXxA0amBSYo6MfSYhLWC7+0YXmxHber 6rfIngGReIyA7BMyyZU6weMVngDCwdCvQkz9bGwsRVNcuXMBIcgy7LANqV+UBAJbkriM /RTLSfe9Dj7v3b801+m+kuENyRwiMi8WFQrv9HQADMMNbzmOlyf2J/LikbtBmdQDo5N9 zd7A== X-Gm-Message-State: AOAM533KdT4wzomtZSMhZzXOqYvqiVYNYNq0gVfCcESBuJe3AOSyJiY4 LGdjJ+BHW44UWS6k6n/OKEs= X-Google-Smtp-Source: ABdhPJxHExqEsLgO7J9y5KnkY1yEERii8lCTOv/3bJAnr9MP0mUzPnpLw4VB4MQIQy2+FxYaUCDvdA== X-Received: by 2002:ac2:561a:: with SMTP id v26mr6360757lfd.602.1621196468675; Sun, 16 May 2021 13:21:08 -0700 (PDT) Received: from pc638.lan (h5ef52e3d.seluork.dyn.perspektivbredband.net. [94.245.46.61]) by smtp.gmail.com with ESMTPSA id y28sm378195lfg.210.2021.05.16.13.21.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 May 2021 13:21:08 -0700 (PDT) From: "Uladzislau Rezki (Sony)" To: Andrew Morton Cc: linux-mm@kvack.org, LKML , Mel Gorman , Matthew Wilcox , Nicholas Piggin , Uladzislau Rezki , Hillf Danton , Michal Hocko , Oleksiy Avramchenko , Steven Rostedt Subject: [PATCH 2/3] mm/vmalloc: Switch to bulk allocator in __vmalloc_area_node() Date: Sun, 16 May 2021 22:20:55 +0200 Message-Id: <20210516202056.2120-3-urezki@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210516202056.2120-1-urezki@gmail.com> References: <20210516202056.2120-1-urezki@gmail.com> MIME-Version: 1.0 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=SuMLTgGZ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of urezki@gmail.com designates 209.85.167.48 as permitted sender) smtp.mailfrom=urezki@gmail.com X-Stat-Signature: umoddjmezf5gf3fk5agoqze8eh1ympia X-Rspamd-Queue-Id: BB464A00038B X-Rspamd-Server: rspam02 X-HE-Tag: 1621196468-947297 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: Recently there has been introduced a page bulk allocator for users which need to get number of pages per one call request. For order-0 pages switch to an alloc_pages_bulk_array_node() instead of alloc_pages_node(), the reason is the former is not capable of allocating set of pages, thus a one call is per one page. Second, according to my tests the bulk allocator uses less cycles even for scenarios when only one page is requested. Running the "perf" on same test case shows below difference: - 45.18% __vmalloc_node - __vmalloc_node_range - 35.60% __alloc_pages - get_page_from_freelist 3.36% __list_del_entry_valid 3.00% check_preemption_disabled 1.42% prep_new_page - 31.00% __vmalloc_node - __vmalloc_node_range - 14.48% __alloc_pages_bulk 3.22% __list_del_entry_valid - 0.83% __alloc_pages get_page_from_freelist The "test_vmalloc.sh" also shows performance improvements: fix_size_alloc_test_4MB loops: 1000000 avg: 89105095 usec fix_size_alloc_test loops: 1000000 avg: 513672 usec full_fit_alloc_test loops: 1000000 avg: 748900 usec long_busy_list_alloc_test loops: 1000000 avg: 8043038 usec random_size_alloc_test loops: 1000000 avg: 4028582 usec fix_align_alloc_test loops: 1000000 avg: 1457671 usec fix_size_alloc_test_4MB loops: 1000000 avg: 62083711 usec fix_size_alloc_test loops: 1000000 avg: 449207 usec full_fit_alloc_test loops: 1000000 avg: 735985 usec long_busy_list_alloc_test loops: 1000000 avg: 5176052 usec random_size_alloc_test loops: 1000000 avg: 2589252 usec fix_align_alloc_test loops: 1000000 avg: 1365009 usec For example 4MB allocations illustrates ~30% gain, all the rest is also better. Signed-off-by: Uladzislau Rezki (Sony) Acked-by: Mel Gorman --- mm/vmalloc.c | 76 +++++++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 5d96fee17226..a8e50278019a 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -2766,8 +2766,6 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, unsigned long array_size; unsigned int nr_small_pages = size >> PAGE_SHIFT; unsigned int page_order; - struct page **pages; - unsigned int i; array_size = (unsigned long)nr_small_pages * sizeof(struct page *); gfp_mask |= __GFP_NOWARN; @@ -2776,13 +2774,13 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, /* Please note that the recursion is strictly bounded. */ if (array_size > PAGE_SIZE) { - pages = __vmalloc_node(array_size, 1, nested_gfp, node, + area->pages = __vmalloc_node(array_size, 1, nested_gfp, node, area->caller); } else { - pages = kmalloc_node(array_size, nested_gfp, node); + area->pages = kmalloc_node(array_size, nested_gfp, node); } - if (!pages) { + if (!area->pages) { free_vm_area(area); warn_alloc(gfp_mask, NULL, "vmalloc size %lu allocation failure: " @@ -2791,43 +2789,53 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, return NULL; } - area->pages = pages; - area->nr_pages = nr_small_pages; + area->nr_pages = 0; set_vm_area_page_order(area, page_shift - PAGE_SHIFT); - page_order = vm_area_page_order(area); - /* - * Careful, we allocate and map page_order pages, but tracking is done - * per PAGE_SIZE page so as to keep the vm_struct APIs independent of - * the physical/mapped size. - */ - for (i = 0; i < area->nr_pages; i += 1U << page_order) { - struct page *page; - int p; - - /* Compound pages required for remap_vmalloc_page */ - page = alloc_pages_node(node, gfp_mask | __GFP_COMP, page_order); - if (unlikely(!page)) { - /* Successfully allocated i pages, free them in __vfree() */ - area->nr_pages = i; - atomic_long_add(area->nr_pages, &nr_vmalloc_pages); - warn_alloc(gfp_mask, NULL, - "vmalloc size %lu allocation failure: " - "page order %u allocation failed", - area->nr_pages * PAGE_SIZE, page_order); - goto fail; - } + if (!page_order) { + area->nr_pages = alloc_pages_bulk_array_node( + gfp_mask, node, nr_small_pages, area->pages); + } else { + /* + * Careful, we allocate and map page_order pages, but tracking is done + * per PAGE_SIZE page so as to keep the vm_struct APIs independent of + * the physical/mapped size. + */ + while (area->nr_pages < nr_small_pages) { + struct page *page; + int i; + + /* Compound pages required for remap_vmalloc_page */ + page = alloc_pages_node(node, gfp_mask | __GFP_COMP, page_order); + if (unlikely(!page)) + break; - for (p = 0; p < (1U << page_order); p++) - area->pages[i + p] = page + p; + for (i = 0; i < (1U << page_order); i++) + area->pages[area->nr_pages + i] = page + i; - if (gfpflags_allow_blocking(gfp_mask)) - cond_resched(); + if (gfpflags_allow_blocking(gfp_mask)) + cond_resched(); + + area->nr_pages += 1U << page_order; + } } + atomic_long_add(area->nr_pages, &nr_vmalloc_pages); - if (vmap_pages_range(addr, addr + size, prot, pages, page_shift) < 0) { + /* + * If not enough pages were obtained to accomplish an + * allocation request, free them via __vfree() if any. + */ + if (area->nr_pages != nr_small_pages) { + warn_alloc(gfp_mask, NULL, + "vmalloc size %lu allocation failure: " + "page order %u allocation failed", + area->nr_pages * PAGE_SIZE, page_order); + goto fail; + } + + if (vmap_pages_range(addr, addr + size, prot, area->pages, page_shift) < 0) { warn_alloc(gfp_mask, NULL, "vmalloc size %lu allocation failure: " "failed to map pages", From patchwork Sun May 16 20:20:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 12260593 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16A97C43460 for ; Sun, 16 May 2021 20:21:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A5B1E61155 for ; Sun, 16 May 2021 20:21:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5B1E61155 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0E5096B0071; Sun, 16 May 2021 16:21:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0BE906B0072; Sun, 16 May 2021 16:21:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E094B6B0073; Sun, 16 May 2021 16:21:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0181.hostedemail.com [216.40.44.181]) by kanga.kvack.org (Postfix) with ESMTP id 95CEA6B0071 for ; Sun, 16 May 2021 16:21:11 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 3C1708249980 for ; Sun, 16 May 2021 20:21:11 +0000 (UTC) X-FDA: 78148213542.17.D8B881E Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) by imf24.hostedemail.com (Postfix) with ESMTP id 364F3A000382 for ; Sun, 16 May 2021 20:21:09 +0000 (UTC) Received: by mail-lf1-f54.google.com with SMTP id z13so5765792lft.1 for ; Sun, 16 May 2021 13:21:10 -0700 (PDT) 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=79GjM4x/Ic55mS6eHRbboPY9tKUJn041OlCHIXbFv7w=; b=esKP1poaxeNM/5km5DjCa/yJ1+ew6bwu6Q3o4XP1drT/teb5LSfaAIEe/uF/TPmAmq uZYWLhiG9HpaB0wCfYjoLMiy7YNqWBCEhuRoB+ohw2TZd3OtrrOi1NrFz5TEjZ3g4O4L kbRzikCEryLvjNuCDCyDVrqmjjCY/XrI0qvhoxqZkhef8Ep4YwPJIbjXfxBDpeNCwyTx q51JJTtRJX1ZU0ghozgsmKMpy0EYlBVEc3hdoyAAXBPB304lGFrxi/VVBfq0pqaUCmso 4r/MMzrjwjUKoFAFO8NDOd8WW5AIRJ1vLC98X9mE+PCDim6U82RdNnqgrMAZcDzCDJN7 jsNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=79GjM4x/Ic55mS6eHRbboPY9tKUJn041OlCHIXbFv7w=; b=fw4vrGtQan/8tV27j9V8gClssP8UBXwT1iPAt/8vMegSrMz42hpU0IdxABj3KpIfmu 5h5xQlono8aqrZ0Ib08QxP9rcorZd1sryNaHaRFF9OPaFRq3PEBPqMW3Qb0JSJEdMZb2 Px7u07wDeqQ4WypZ3u5VxS02tRNAyJl7aAV0S8qiVIEIEFBdfP27W8dkkEeaRzOMSlt+ z6AME6MIKBG+u1TihPUvH85k0U04MGgcAIi6AGLoPd7Z384Fc5Q7wSGBvjW1FuKRoHkt M5MfUDnp3LLbu2LFl8z8meZfWWO1PXA3FAGCywo0ULXyQB35+vKPW2fqPYdahT8Zths9 ArXw== X-Gm-Message-State: AOAM531InS1isIKAiNJ0eQ1G9icPFl8EXuLt/x5OpLN6+D2UQ8boha6G t+TN7M0vPruucQvAoL6XG6o= X-Google-Smtp-Source: ABdhPJy7wLHLdLMs4geBfOKh0U6fw0Z8tEv4vgtjJcHlMaTkZm3NcKvFoEDlb3xwhrSSZ8Hrd4jyMw== X-Received: by 2002:a05:6512:21d:: with SMTP id a29mr6952310lfo.391.1621196469636; Sun, 16 May 2021 13:21:09 -0700 (PDT) Received: from pc638.lan (h5ef52e3d.seluork.dyn.perspektivbredband.net. [94.245.46.61]) by smtp.gmail.com with ESMTPSA id y28sm378195lfg.210.2021.05.16.13.21.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 May 2021 13:21:09 -0700 (PDT) From: "Uladzislau Rezki (Sony)" To: Andrew Morton Cc: linux-mm@kvack.org, LKML , Mel Gorman , Matthew Wilcox , Nicholas Piggin , Uladzislau Rezki , Hillf Danton , Michal Hocko , Oleksiy Avramchenko , Steven Rostedt Subject: [PATCH 3/3] mm/vmalloc: Print a warning message first on failure Date: Sun, 16 May 2021 22:20:56 +0200 Message-Id: <20210516202056.2120-4-urezki@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210516202056.2120-1-urezki@gmail.com> References: <20210516202056.2120-1-urezki@gmail.com> MIME-Version: 1.0 Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=esKP1poa; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of urezki@gmail.com designates 209.85.167.54 as permitted sender) smtp.mailfrom=urezki@gmail.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 364F3A000382 X-Stat-Signature: jnyuw7r6rcxs8jwbqi65w8c6o67mb4mt X-HE-Tag: 1621196469-271337 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: When a memory allocation for array of pages are not succeed emit a warning message as a first step and then perform the further cleanup. The reason it should be done in a right order is the clean up function which is free_vm_area() can potentially also follow its error paths what can lead to confusion what was broken first. Signed-off-by: Uladzislau Rezki (Sony) --- mm/vmalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index a8e50278019a..b2a0cbfa37c1 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -2781,11 +2781,11 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, } if (!area->pages) { - free_vm_area(area); warn_alloc(gfp_mask, NULL, "vmalloc size %lu allocation failure: " "page array size %lu allocation failed", nr_small_pages * PAGE_SIZE, array_size); + free_vm_area(area); return NULL; }