Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1099500ybe; Mon, 2 Sep 2019 14:30:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMmWUv0ZmupWfsYDOLXZzX88Ba+Cloxao3tdL8eIpigboF5Pb9oHMBFqMDNj2P5dbD/63M X-Received: by 2002:a17:902:8488:: with SMTP id c8mr29823624plo.164.1567459829861; Mon, 02 Sep 2019 14:30:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567459829; cv=none; d=google.com; s=arc-20160816; b=w5Mp98AA/LzpK5jXzUaT+TYDNJzHwVQfaKVoBYEfh7xEwhLpc0734Bw+iFk6+x6aMx p5eeRrJnCoCKmJbgoDusm8wupejL76W+C4e/tpb3Ql7FtFWaD82rxD+sw9IRUmBcrKD2 0NbpFVjT4BSPUAAw9nqB1HgCJG9eK621iCgLG0afXNmZzLy8aCKKD5ZMEa1LRTI2PpvE XzlviWqNwRgZVdsVcc+tWFCITAblzDkyF/gHvcZOIw3x9EcpFGKEJBLrOzIcFsuuEuAp Oy4P67n0rDTOeEgi/BvrB5IvwTz2iZ3B1DPRRbWrNjh9g5TadphGj7OBYBDV41VVmAi4 XxHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=m5Tr8peCYLPTBLyG4jlj+OLhYRR0ev+4cBo1n2zucSI=; b=nRNmZnzqIrWWGNKNNSHrDAgV7VQWIS0P+trgb0TXcymGFogqDoB+x5zZRJ2FvQwNiE ihXwJL+CUbCqqQBloE433JqtiLA3YNqZjZKvR4o7ChhVazkLflkg7x7DVY3iTp91q9K7 JwjqNFe4e2ZEEfya3ikTN2nm7hv6tpZCgpuex6WTpfk2MLhSFAOe6jrqY2+xyAr9EvtR i6QpKvkGW7i++qpu6rS50ozdycpz9XLuPkopKqUX6qPFWyUCzm8lZf0Ef7rCWulT982i LYfAF5spgRpG3pzYyaKfT7h5tZk+MSdCKIDw8MROkWmbjndjOhX/sP8KohHZXq6UHrzR A/Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E7XWS51m; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id w16si12632110pjn.71.2019.09.02.14.30.14; Mon, 02 Sep 2019 14:30:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E7XWS51m; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727603AbfIBV2N (ORCPT + 99 others); Mon, 2 Sep 2019 17:28:13 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:36771 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726964AbfIBV2N (ORCPT ); Mon, 2 Sep 2019 17:28:13 -0400 Received: by mail-qk1-f196.google.com with SMTP id s18so2666937qkj.3 for ; Mon, 02 Sep 2019 14:28:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=m5Tr8peCYLPTBLyG4jlj+OLhYRR0ev+4cBo1n2zucSI=; b=E7XWS51m3HrCCTEixm5DCt3mCnbxRvgSDNLcJNwLa+R4y1JIjfRngyCAtllxj7BiDV QXSvevY8BokCCfeECi4pWRDaupFZQ6gaOBdFwoHvyuMn3hh0ueJtchjxb+/pZ8fibZYY AYtVk6gogONa8YRAddmi9iNLn6SXWOFGuBgPDbLmI0UuopSdZgtT1FPRv+5bJUSzP9Ju Lp/778ylNxlmOoTesZOF75ZgMBtAvAZfz+aBqMBpvhIIT6JS2KUHJOA3k9DtmPGZktjy CxFywRTqNgyBJQfWJmuN4Cf3XFB/HBs9BONoBLBlwdhhpJYf+0HjHk7gWvjCEJnoo1qM zx8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=m5Tr8peCYLPTBLyG4jlj+OLhYRR0ev+4cBo1n2zucSI=; b=nwH+8qmzS199CHLje1AsBcdVNyqfU3tJ9FwSF2AlLNDGJaLLIK2IfEHbYhfyfU0Bek dWMpOKTvUE2x4tY3eiKklCFAkUSTy2PB84uPdc76UoCEn9zw+LCgfFJR+aKAfaqzgGqL JKLcF6PMUfrdQCG9iM/89/rKzW5UBvZeVQqdubaPQJYJniFcP4wPTKIH23SraI/llrXC 2pH8suMQ63KqaIiYVtwidB0bUV+CBftiJS/zXAFoqkB1K0TFMYrfVAdGbqsAbtIbGWa/ z751GTNfPxAqizQP/Hxkp6aSctwOHITNepj5ZdB1qyXWX1XW1ofF3P7Q/oIexmimn8rO qYsw== X-Gm-Message-State: APjAAAUZmJB40Fi0E2lhWVr4oH0mhn9ctK/X9i/GrPGnIwJnb4cEmQOC cDzRkwYhkbS58KhwOy8I3DHAbIIMaRAomVChd2g= X-Received: by 2002:a37:8684:: with SMTP id i126mr18173762qkd.433.1567459692698; Mon, 02 Sep 2019 14:28:12 -0700 (PDT) MIME-Version: 1.0 References: <20190830035716.GA190684@LGEARND20B15> <20190830135007.8b5949bd57975d687ff0a3f8@linux-foundation.org> In-Reply-To: <20190830135007.8b5949bd57975d687ff0a3f8@linux-foundation.org> From: Austin Kim Date: Tue, 3 Sep 2019 06:28:08 +0900 Message-ID: Subject: Re: [PATCH] mm/vmalloc: move 'area->pages' after if statement To: Andrew Morton Cc: urezki@gmail.com, guro@fb.com, rpenyaev@suse.de, mhocko@suse.com, rick.p.edgecombe@intel.com, rppt@linux.ibm.com, aryabinin@virtuozzo.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2019=EB=85=84 8=EC=9B=94 31=EC=9D=BC (=ED=86=A0) =EC=98=A4=EC=A0=84 5:50, A= ndrew Morton =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84= =B1: > > On Fri, 30 Aug 2019 12:57:16 +0900 Austin Kim wr= ote: > > > If !area->pages statement is true where memory allocation fails, > > area is freed. > > > > In this case 'area->pages =3D pages' should not executed. > > So move 'area->pages =3D pages' after if statement. > > > > ... > > > > --- a/mm/vmalloc.c > > +++ b/mm/vmalloc.c > > @@ -2416,13 +2416,15 @@ static void *__vmalloc_area_node(struct vm_stru= ct *area, gfp_t gfp_mask, > > } else { > > pages =3D kmalloc_node(array_size, nested_gfp, node); > > } > > - area->pages =3D pages; > > - if (!area->pages) { > > + > > + if (!pages) { > > remove_vm_area(area->addr); > > kfree(area); > > return NULL; > > } > > > > + area->pages =3D pages; > > + > > for (i =3D 0; i < area->nr_pages; i++) { > > struct page *page; > > > > Fair enough. But we can/should also do this? I agreed since it is the same treatment. Thanks for feedback. > > --- a/mm/vmalloc.c~mm-vmalloc-move-area-pages-after-if-statement-fix > +++ a/mm/vmalloc.c > @@ -2409,7 +2409,6 @@ static void *__vmalloc_area_node(struct > nr_pages =3D get_vm_area_size(area) >> PAGE_SHIFT; > array_size =3D (nr_pages * sizeof(struct page *)); > > - area->nr_pages =3D nr_pages; > /* Please note that the recursion is strictly bounded. */ > if (array_size > PAGE_SIZE) { > pages =3D __vmalloc_node(array_size, 1, nested_gfp|highme= m_mask, > @@ -2425,6 +2424,7 @@ static void *__vmalloc_area_node(struct > } > > area->pages =3D pages; > + area->nr_pages =3D nr_pages; > > for (i =3D 0; i < area->nr_pages; i++) { > struct page *page; > _ >