Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2645702lqt; Mon, 22 Apr 2024 18:10:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXznkkywliXsRPtzmKThQ5uTzcKegDERCZyMagLMOdfMR4aAuXZl07pbBPPQAEgOG1JN7NmRnpzq2VzPi2YVaJxHFGCakH59MrgVkbTBA== X-Google-Smtp-Source: AGHT+IFfO3Tv/ZmlcdB5kRh8HFoDzJfAuO+DRNOw+3/7gvryzxBFxOYXp2SuPUHDqav1geSYeG4u X-Received: by 2002:a05:6a21:164a:b0:1ac:3eb4:b91a with SMTP id no10-20020a056a21164a00b001ac3eb4b91amr12175341pzb.11.1713834615965; Mon, 22 Apr 2024 18:10:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713834615; cv=pass; d=google.com; s=arc-20160816; b=I6bDxOo7Cnl++WvKScP+cI71SG7eER+DlOJw4ZrkCqlf/We9b8geg9pn8xwg0Dqaf3 Z8BJs+5lV7thjD0zo1V2oMa/nEduc/pZBEjHcpIv5UQGNeRHUMVsNtU4QKCF7jmW7PMR 7HAai82TxBV5xVPBfpRNrtAUFz7ptCuZfG1s/Zpluhm02J8utuoLA6jxMs5fZK6BPhCZ 6pnWxzmmP7vHALSKazke1dNxd7e3XfosxTaF7Gu+LVAsqCkmMT4+ar/kPfFqdhcibLVM 9n5u0rpxturgsZcrciBtOzT2uZAWhQHq4bS31+sFwiNbRs4P/mq7dCmZgW4hf/4bsjW4 lHgw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=ClL00ZKNnFMRV8+vNcFNoNRUVtaZiDabBBHCITme6cw=; fh=TaZRHybvotpkbbw23dUgmnCdrndw4z8ddrOJh45RMlc=; b=Wg3qR7uf6NX1RCxDkryDVcvlpo6o51RG76VyXsgcnvcr7otMqe5yy6hQoUL73U7lSi LscKXHdqlhPFpW0jqtttZ9ufiuikG1CThwvfjQpbdq0vJ6M4sP004hyqbR6oX/R/kDnf gN0HNbt0EmcdJk1jKLN3mKqEEuAaOahCN1834roA0OuSmIEDmTUTUIhhTrMIBfHDJX/Y 9wt2FcnRX2ALHr5sizIfUdfCHoxs5kDVxA+e8CRPj93nxRYxGAUAy3QzeTi7ohJ81srJ jNbfR42Ir0xlUtv2aZjB58uwV7LMVrkX7eMtpiSu0dlUwtIA6oJPHJztUSfbS4ynjkkd Ga+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=N4DwEXFM; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-154367-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154367-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id s71-20020a63774a000000b005f7fe8660afsi6642397pgc.560.2024.04.22.18.10.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 18:10:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154367-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=N4DwEXFM; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-154367-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154367-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 5364AB221FF for ; Tue, 23 Apr 2024 00:52:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 13773DDB8; Tue, 23 Apr 2024 00:52:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N4DwEXFM" Received: from mail-vs1-f48.google.com (mail-vs1-f48.google.com [209.85.217.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D804A322A for ; Tue, 23 Apr 2024 00:52:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713833547; cv=none; b=DtH9Vp6N2kThEWXnRx8JZmyQYYQf/f0eAOZk626aBzJOVOnyMfPyx8xGKb2Mp/v8shuSgQyXS0iailXjhV2uUlptkPK1i+c9SD0ElqiGZsB5rb3hEytjTVQ5tlYj0Ds4MkhJ6kIbspZnRp8RhWFpWyxNkI3zKQ0wlVWRUb6uhTI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713833547; c=relaxed/simple; bh=uclba+Y0I2KbZEt7WfVM1d6DNt4IOCvoMxSQvBBaLoA=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=m6PLaU13jbciwvTeMjYTKGTJz9xZhwEs0lPgzmf/T5XGEgEKx/jWWDq7mAuexjQkL/nVvDt9lMMpz16utVabwCbKCfHMSRu4dCfuwD0V4bmKYM1ekhwi3n1h8hBurgfmnP2dmDcq1ugU7MJ5f/rZXn6CFv1tL+SsEYW6vOQJgrg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=N4DwEXFM; arc=none smtp.client-ip=209.85.217.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-vs1-f48.google.com with SMTP id ada2fe7eead31-47a21267aa8so1673876137.3 for ; Mon, 22 Apr 2024 17:52:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713833545; x=1714438345; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ClL00ZKNnFMRV8+vNcFNoNRUVtaZiDabBBHCITme6cw=; b=N4DwEXFMsXbL6Wk9IFHZQzhlWYNH1/Ft42oSXV/hONC6Ida74bTCBEkmofMGptqZlu qrtWeQEoSaeMdXRs8O3hpAdU3iB4vI+IFwQRpKveVI3aW7kck/v41lR5iMkHevKSxv1F +cnRXlh7sJ2T7f+Fiq/hjJyYMJVYNBi0jUpwmlK9LTAJJmjwdZ20dNuzQ51z3JKQUQua GG9pU3kwuDNTNQ0N+vTWDK+8301E4tCeWWR8wHfVUl444Jj9avrOhELC4SMDLOtZTXe1 QwSv7NxiJtoK64oyGI91QnFjjd5AtpPO0y+QVeU3IB8katUwOrnokX2J4C1Rc4+37dgZ hXjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713833545; x=1714438345; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ClL00ZKNnFMRV8+vNcFNoNRUVtaZiDabBBHCITme6cw=; b=cYGXUR2k4cECarMz+nA0UU3E4JHiMnwdKPzKmgjySn6THkwrseS81iqXOGrmsQvGkX ye7azYFGDvC4GC/g90EoYYWd0+u51Gv+Q97kzWNCFqMYRWGSU1deIrySHomKQ7ldv/HX I7ERwBVzPa+DBXJCoFxUCcl+aDbk5HyQallBpUkKpnu8YbrCyiOmNhjJhHP5zhVY9BMK vpYTLHLINEU4KCzI8tbR9aoWDaAg2iSgUVlSY6LoFDbwye5lT5JkLYp2E2p7TgQm4/24 q4YgW1NxNlsffMlZC0COrt8rwlHQneB8LsTkv2zVxx1xDP301D4EYQzNOg0ZGX/uCuFQ 3ppQ== X-Forwarded-Encrypted: i=1; AJvYcCWiZogcm+mT8ZdaIZ+qieZblTkotx8Blx0/XBruO7fG4gUtlLRDTHtieWclkjlneLk944CduogycpxrPKIOw3M7/fUQkY5wUjrPW5Ur X-Gm-Message-State: AOJu0YzdbK7MNX1sATZBY1UvAeVrxpWALar9+dXkpHjM9lAKE/1QskMl 7r63LoLYccsmbBbrso8NTWaSyleAWiKg7/wnsCKRg/Ub1A5S2/1mchAtyAqK3KWoKqaVRavn4Ag Mu5NE28F2/o36R9z7+pH9ZiqjVws= X-Received: by 2002:a67:e24c:0:b0:47b:bf92:691 with SMTP id w12-20020a67e24c000000b0047bbf920691mr13868061vse.1.1713833544690; Mon, 22 Apr 2024 17:52:24 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240419101643.11534-1-hailong.liu@oppo.com> <20240422103857.qw5mrcnj4rgej2jh@oppo.com> In-Reply-To: <20240422103857.qw5mrcnj4rgej2jh@oppo.com> From: Barry Song <21cnbao@gmail.com> Date: Tue, 23 Apr 2024 08:52:13 +0800 Message-ID: Subject: Re: [RFC PATCH v2] mm/vmalloc: fix return value of vb_alloc if size is 0. To: Hailong Liu Cc: akpm@linux-foundation.org, urezki@gmail.com, hch@infradead.org, lstoakes@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Apr 22, 2024 at 6:39=E2=80=AFPM Hailong Liu = wrote: > > On Mon, 22. Apr 11:46, Barry Song wrote: > > On Fri, Apr 19, 2024 at 6:17=E2=80=AFPM wrote: > > > > > > From: "Hailong.Liu" > > > > > > vm_map_ram check return value of vb_alloc by IS_ERR. if > > > vm_map_ram(page, 0, 0) , vb_alloc(0, GFP_KERNEL) would return NULL > > > which cause kernel panic by vmap_pages_range_noflush=E3=80=82fix this= by > > > return ERR_PTR(-EINVAL) if size is 0. > > > > > > Signed-off-by: Hailong.Liu > > > --- > > > Changes since v1 [1]: > > > - Return ERR_PTR(-EINVAL) or not check IS_ERR_OR_NULL > > > > > > BTW, Barry suggests me that if count is 0, return directly, in my > > > opinion, change return value is more resonable. > > > > > > [1] https://lore.kernel.org/all/84d7cd03-1cf8-401a-8edf-2524db0bd6d5@= oppo.com/ > > > > > > mm/vmalloc.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > > > index a3fedb3ee0db..c430a999805b 100644 > > > --- a/mm/vmalloc.c > > > +++ b/mm/vmalloc.c > > > @@ -2173,7 +2173,7 @@ static void *vb_alloc(unsigned long size, gfp_t= gfp_mask) > > > * get_order(0) returns funny result. Just warn and t= erminate > > > * early. > > > */ > > > - return NULL; > > > + return ERR_PTR(-EINVAL); > > > > might be ZERO_SIZE_PTR. > > Hi Barry, > Hi Barry, I use ERR_PTR(-EINVAL) to keep consistency with the return > value of the function alloc_vmap_area. > > if (unlikely(!size || offset_in_page(size) || !is_power_of_2(alig= n))) > return ERR_PTR(-EINVAL); > > IMO, ZERO_SIZE_PTR is used by slab and can not be catched by IS_ERR(). Ok. it seems not worth to change two places. Reviewed-by: Barry Song > > -- > Best Regards, > Hailong.