Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp132682pxb; Fri, 29 Oct 2021 07:07:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcyC+NDSkQQNMh6+jbJ1gwtKllrbg6z2rk7DuwSABhoJOFaQRTjPMnMPtvUj6LWjQVQZCe X-Received: by 2002:a5d:83c7:: with SMTP id u7mr7967701ior.80.1635516471736; Fri, 29 Oct 2021 07:07:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635516471; cv=none; d=google.com; s=arc-20160816; b=SDy1K2lL6y/ZWc33f+qGvkl5JGECB1c/OPeNlsDHyiZ3Tq6dpZbekr/OwnJs+Q5Ri/ awzm+cb7DbF4lPGSoXfkFVKTE5kw+u/4l3EA3JZnwP4vFAXoB+kF8kBPSg1tmPUibKyB dqIEw1T5Pa4cz6YABdvzc+4Jt9bqs2c5oGPLG7L9Wi+w9lvqjZTZB9Xn9bPd/ZyJi+jO W137xCOMpCKUE45PgMMqtgYGItkZe7DrwEwGghrvYz6/ppk+D7EOiag4vgztZO7LA29C a+L0X4zkPXgq5Dk8Zj31GNr8UmiIhcteT/2CHLh6ae/UJhMsJ2min7gX43jUUJbXa9hH q6Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=hvaOZ+L7Q/hsGmgFIj1Fd0g2K7g1gQBbyCtdTWJts7g=; b=tGSNPSEJ7ifVxrU2avf4N+zfad/kWDA86awwQmm5Ig5VW/Foo54wDJ0xrQW79oJio9 D+0fbOgZPqW2u32nVw29rgqM5b6DgTJsCi/N06fgnDZlX+cCH6t5XWjVx+fEKMQ0gQc1 VuTZJ3OA/Cb1TVBiil7uLoVULJQWuGdpcKbZBQ6bne5tpaMART/h0mGVS6FWdFrsmmQV zsM3pSvkoDfus2hOzYt5H0Yn5JYjCMeHsj8GJB9OHFyYQV+scXdBA2TjUu0KZadP/2pQ RIIWPBxT4ZR7SY+8F3y1UBJp6DOKEEdxgI6U72dYS84ik1rcd0ZXWUUzAiG5Vk3v2Eny jhlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=k3ESfV5Y; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w11si10455386iov.94.2021.10.29.07.07.38; Fri, 29 Oct 2021 07:07:51 -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=@gmail.com header.s=20210112 header.b=k3ESfV5Y; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230521AbhJ2OIQ (ORCPT + 99 others); Fri, 29 Oct 2021 10:08:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229603AbhJ2OIP (ORCPT ); Fri, 29 Oct 2021 10:08:15 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A811C061570; Fri, 29 Oct 2021 07:05:46 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id r4so38459479edi.5; Fri, 29 Oct 2021 07:05:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hvaOZ+L7Q/hsGmgFIj1Fd0g2K7g1gQBbyCtdTWJts7g=; b=k3ESfV5YtenEJ/NOkxsM84lYLQWIN00Dm9aqiA9jgI4swsqfLAEkI/ab/eKHSqMRQr Zj6jmYK3kTsyMGKTF46IYBnC65esbPtG9eEg6U7YAKzp5N3GvpBL7m57hAAQ2hClX4oL 0XtFIryldx8HXL7f4vipSifahc6nJv6O/REYNJB9+04h4Yp2kRwNK/u3tDU+ZzV/FjrO 2PaoSXeQpwQ3EhZKPi4HSaQWhasznxo33DgG2xTeSJof53lpP4JqDCPOZGCNGPLVBvkw RRvkCxr1Gj1KxPALv6tPGhGscizSde7P2504Tp9EpMbS0ki3n59anIoFZcvNSHrfmJqM yW5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hvaOZ+L7Q/hsGmgFIj1Fd0g2K7g1gQBbyCtdTWJts7g=; b=ncqDEzdp/RET4q9jvA0bH71Q8nRJgreqnJ8Jz223h4/Y/mEBEB5mLCWjnv/jz5nnKe XHv9CxQ6D1v6ktNVxGK7DbJNbhmxIMD+7yOUeLFO6EaCZB8mqRLpn+wuR8Ud7oshwRgV j3Yl4HjEN9GEItKybCNJ1kXYd5433KxBiRT6M74w0J+/6rPX12j13E+eXvanuX+s3saQ J9vv8xF9KQMCqLJDMsPSwJK1K1Iy8t+6amJWyd4W3EVP80kflAX5JJWYFkwfb/r+y3g0 2Flu02NOGL+zIeY7U3w/aPw9qluiRAyOg/9BkhRCI7po5bbsEVxcbt5JSmzMXxph6i5g mR8Q== X-Gm-Message-State: AOAM5337tUpx4PMyjjDYR+xWAq9C1cxA4cgoqlnc/XOz8MWLjdQlGO/u bVzqteo7FR8NiTgXXQs/dh4Mlgwn5MgQcZVL+EI= X-Received: by 2002:a17:906:58d3:: with SMTP id e19mr13384663ejs.350.1635516343380; Fri, 29 Oct 2021 07:05:43 -0700 (PDT) MIME-Version: 1.0 References: <20211025150223.13621-1-mhocko@kernel.org> <20211025150223.13621-3-mhocko@kernel.org> <20211026193315.GA1860@pc638.lan> <20211027175550.GA1776@pc638.lan> In-Reply-To: From: Uladzislau Rezki Date: Fri, 29 Oct 2021 16:05:32 +0200 Message-ID: Subject: Re: [PATCH 2/4] mm/vmalloc: add support for __GFP_NOFAIL To: Michal Hocko Cc: Linux Memory Management List , Dave Chinner , Neil Brown , Andrew Morton , Christoph Hellwig , linux-fsdevel@vger.kernel.org, LKML , Ilya Dryomov , Jeff Layton Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > > index d77830ff604c..f4b7927e217e 100644 > > --- a/mm/vmalloc.c > > +++ b/mm/vmalloc.c > > @@ -2889,8 +2889,14 @@ 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; > > + unsigned long flags; > > + int ret; > > > > array_size = (unsigned long)nr_small_pages * sizeof(struct page *); > > + > > + /* > > + * This is i do not understand why we do not want to see warning messages. > > + */ > > gfp_mask |= __GFP_NOWARN; > > I suspect this is becauser vmalloc wants to have its own failure > reporting. > But as i see it is broken. All three warn_alloc() reports in the __vmalloc_area_node() are useless because the __GFP_NOWARN is added on top of gfp_mask: void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...) { struct va_format vaf; va_list args; static DEFINE_RATELIMIT_STATE(nopage_rs, 10*HZ, 1); if ((gfp_mask & __GFP_NOWARN) || !__ratelimit(&nopage_rs)) return; ... everything with the __GFP_NOWARN is just reverted. > [...] > > @@ -3010,16 +3037,22 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align, > > area = __get_vm_area_node(real_size, align, shift, VM_ALLOC | > > VM_UNINITIALIZED | vm_flags, start, end, node, > > gfp_mask, caller); > > - if (!area) { > > - warn_alloc(gfp_mask, NULL, > > - "vmalloc error: size %lu, vm_struct allocation failed", > > - real_size); > > - goto fail; > > - } > > + if (area) > > + addr = __vmalloc_area_node(area, gfp_mask, prot, shift, node); > > + > > + if (!area || !addr) { > > + if (gfp_mask & __GFP_NOFAIL) { > > + schedule_timeout_uninterruptible(1); > > + goto again; > > + } > > + > > + if (!area) > > + warn_alloc(gfp_mask, NULL, > > + "vmalloc error: size %lu, vm_struct allocation failed", > > + real_size); > > > > - addr = __vmalloc_area_node(area, gfp_mask, prot, shift, node); > > - if (!addr) > > goto fail; > > + } > > > > /* > > * In this function, newly allocated vm_struct has VM_UNINITIALIZED > > > > OK, this looks easier from the code reading but isn't it quite wasteful > to throw all the pages backing the area (all of them allocated as > __GFP_NOFAIL) just to then fail to allocate few page tables pages and > drop all of that on the floor (this will happen in __vunmap AFAICS). > > I mean I do not care all that strongly but it seems to me that more > changes would need to be done here and optimizations can be done on top. > > Is this something you feel strongly about? > Will try to provide some motivations :) It depends on how to look at it. My view is as follows a more simple code is preferred. It is not considered as a hot path and it is rather a corner case to me. I think "unwinding" has some advantage. At least one motivation is to release a memory(on failure) before a delay that will prevent holding of extra memory in case of __GFP_NOFAIL infinitelly does not succeed, i.e. if a process stuck due to __GFP_NOFAIL it does not "hold" an extra memory forever. -- Uladzislau Rezki