Received: by 2002:a05:6520:4211:b029:f4:110d:56bc with SMTP id o17csp1621627lkv; Wed, 19 May 2021 14:16:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyM0P7Xy83pYYUs4MeLFzw5tH1M5LjVhJt8Jnk6qwAsHYjR2+QmOQdCiDK8DETL8tJ2BbnF X-Received: by 2002:a05:6638:2594:: with SMTP id s20mr1388085jat.140.1621458960341; Wed, 19 May 2021 14:16:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621458960; cv=none; d=google.com; s=arc-20160816; b=enWU4HkuqLAfjjFoorZ41CRWeqIzqD6m3jcuJXcnMES0IuljjuydfY8/qoHlxull+N tDlf//wf4UatF5JM5WVbxiIYIrIiaohSM7RCBemq5Wqoiin7yZi+yfRjT7iJVCNL2vpT FojldcckWHw63BFCwmDiswXU43A/jKmmNkODdpIv2ViiEHkDbNngknnxjW9gtEdstUHR JOJEb7XsY5+2k7Rg2sFlZp+b1NWv+l6QeSY40yRC00MkzlGQz9IiJemCVoZIp1Ksa7Ji WnQqliuovTmhfUSCgkje9eCx13lkA6xzx71YfE3LT6rqcqMSQlfNcidd7Cau44xiVs1G uw+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6cgVXjYuC8nAsxdiKYXOmR2kYogLXyfB8N1EBy5OUXY=; b=kx12eEjFD7h5jJDjItRoJCbdUWOB5xOv0MWptP3rzKQ+fN/KZHYIoulic2PZQjhu/2 Wwd1wEyvyjJO79jMq89lH9ldklemlkT/l3yCffhVE2YBxIsL9ft1EJVVHZqvZrfZAFWg bclbTGahLXxaj2eV6yWRGz4zCcDz4qQewxmnnviF/bCGztqF3iidxR7nWXdyOAfpU/YI WTuj0tb2PZxxIdPli2mc37rbrO8/EkuJju+i+6+LVdfV2D7Y+epDoumVnfkXKBFza/cY WZs2+wJzszE02l18XHA4TebVyxPRgkhC3w+AJA/TuRrkPxKWWslanW7UB5ztJQqlASGG 2+hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=HaSU3bhw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u8si775217ilv.32.2021.05.19.14.15.47; Wed, 19 May 2021 14:16:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=HaSU3bhw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240231AbhESNr5 (ORCPT + 99 others); Wed, 19 May 2021 09:47:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239757AbhESNrz (ORCPT ); Wed, 19 May 2021 09:47:55 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9BBFC06175F for ; Wed, 19 May 2021 06:46:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=6cgVXjYuC8nAsxdiKYXOmR2kYogLXyfB8N1EBy5OUXY=; b=HaSU3bhw5jnd4qwqpRENnQ93F2 yLj8+K0nqAnZ+MvNqAMILNmedsd6NnrvC/ebJ9IMjGxCW1Nwl7ehR6cDiwa/t1g+Hir5NageHI1kn xFk1M8kSTmnYb9g9EFaBkO014Y6XzNPvY9t7OVqg5W9PXBz+G0iTSmvXpg3VXkqe8T9WRMq2dFgXj F/BzzEnedATvDETuEqM/tAdrKX1oBgV0+HDJ7qUwVimFOwyFz09QBSrQB1BjuiF/zaaV635GAiRnC 3QBanmjgsg5IBBCBf/qZWGiJY2O6FWWd/Y8FEro/txJDzxZmufmnG2S+ZS15Zu8fSFk6L/6DcKKzu 8SrPcmoA==; Received: from hch by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1ljMUa-00EzH5-SA; Wed, 19 May 2021 13:44:22 +0000 Date: Wed, 19 May 2021 14:44:08 +0100 From: Christoph Hellwig To: "Uladzislau Rezki (Sony)" Cc: Andrew Morton , linux-mm@kvack.org, LKML , Mel Gorman , Matthew Wilcox , Nicholas Piggin , Hillf Danton , Michal Hocko , Oleksiy Avramchenko , Steven Rostedt Subject: Re: [PATCH 2/3] mm/vmalloc: Switch to bulk allocator in __vmalloc_area_node() Message-ID: References: <20210516202056.2120-1-urezki@gmail.com> <20210516202056.2120-3-urezki@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210516202056.2120-3-urezki@gmail.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > + 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 Comments over 80 lines are completely unreadable, so please avoid them. > + * 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 (i = 0; i < (1U << page_order); i++) > + area->pages[area->nr_pages + i] = page + i; > > + if (gfpflags_allow_blocking(gfp_mask)) > + cond_resched(); > + > + area->nr_pages += 1U << page_order; > + } In fact splitting this whole high order allocation logic into a little helper would massivel benefit the function by ordering it more logical and reducing a level of indentation. > + /* > + * 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; > + } From reading __alloc_pages_bulk not allocating all pages is something that cn happen fairly easily. Shouldn't we try to allocate the missing pages manually and/ore retry here? > + > + if (vmap_pages_range(addr, addr + size, prot, area->pages, page_shift) < 0) { Another pointlessly long line.