Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2709245ybh; Mon, 9 Mar 2020 11:22:14 -0700 (PDT) X-Google-Smtp-Source: ADFU+vusLztHCZBSdOrFnBb19qpyYsRxHrssaRmgZKOc5i7hUsTTCuF2lEvZP5fs30YznmuK1RZx X-Received: by 2002:a05:6830:c9:: with SMTP id x9mr14136436oto.8.1583778133834; Mon, 09 Mar 2020 11:22:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583778133; cv=none; d=google.com; s=arc-20160816; b=S9IFL3gylmRlUKdONMw0/UQnERwzPgKn2IU3NOBIXJFGqjkXDxsOEETZpJRCEWGpVm i2XwZ6nTnX9JcK4LyMc2OriSsYR9MU9LqfUs9wI55UHoOUkYahZlMxRtGz/hWD/0tCpH 6QyxXFHaFI6F398OV5DGJRj0jPA14KIbm4zNb/SDXGBbS3s6mE2PIhsVKIN+5ha5f41M 0oN6lSFZdfCAfwRVlTOoBsTVu8tkVwYRJwC0U/TD5xdm560f4eQ6Z7+GxyAl58JVtgc1 0pZLpkEkTT4YgX7odIc/4qyaxr31aJI7mCzKF25RxEzoCViyZTL6aNq2/x3qIBdteBwz 7RTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:to:from:subject:cc:date :originaldate:in-reply-to:original:originalfrom :content-transfer-encoding:dkim-signature:dkim-signature; bh=Dj8K1Y9A/sg8En4uAWfo+rhEOVoMBMW9TFciIFvXrkE=; b=BqcY/j84wjAdu3jJp8p3C8F7ilhBy/UBD0/NNnCuFmVGIbnW/ywiGC2r+LbkwlReGo bIHJqyDNrCnN0A8RB9TQjap8jZIf7/XhzgJQf5lQnPAHiTpNyBtHCTr/XMipXrz9BGg4 9uQEEOv1N2+7UcLjvOUPR2ckiJcPvs6lssOwyKu72fzS0Y303vqmH/+SIa0esJuBPcrf QzQsItGWpA48l25mCfj3WYxtMrEJ4p0ksloKZtVi/8FlBBTbTtm0ZXfvN771rRRr4zHp 5P0wlu1EoTcTookmgEC9dvzLlNFdSTKEmQcuhBShD0I1+H67TklO3p2r7Rk/Tg9O5sZ4 MYRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm2 header.b=bZuCeSSW; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=22A3LS72; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r19si6416319otd.106.2020.03.09.11.22.01; Mon, 09 Mar 2020 11:22:13 -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=@dxuuu.xyz header.s=fm2 header.b=bZuCeSSW; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=22A3LS72; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727417AbgCISVi (ORCPT + 99 others); Mon, 9 Mar 2020 14:21:38 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:40231 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727323AbgCISVh (ORCPT ); Mon, 9 Mar 2020 14:21:37 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 1336E21B6B; Mon, 9 Mar 2020 14:21:36 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 09 Mar 2020 14:21:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dxuuu.xyz; h= content-transfer-encoding:content-type:in-reply-to:date:cc :subject:from:to:message-id; s=fm2; bh=Dj8K1Y9A/sg8En4uAWfo+rhEO VoMBMW9TFciIFvXrkE=; b=bZuCeSSWq8fdUjsWIYiXViPPtFUijVzJJqyfWz8RD j2/DY/zLoVyKzJoIBj9Nx6EcdQY9qnVeWyQXPurcNir6/dV6HhcXESlOKquWL+oV fkrlFouUR5dexW/dFMzJRxEh2jN7kSqIBSC2evA0hlKfWn7YGJ4jmsvjmMkd0eOg JMixXV0tw6bKBLwQxAEsq3JpxdniJBeIYQkKIYwnpsiECzKbhqp3x3tppviJv/F7 2VBbikfuB/obg++ywvEAf/6g9dRpn7wvdKaUf5d+zdJTTSH2JwLACpVEo+tb/Pru NywFXqw9X6DXUNRAqnATJWqa4HkvxYbuV/nKjPrABWy5g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=Dj8K1Y 9A/sg8En4uAWfo+rhEOVoMBMW9TFciIFvXrkE=; b=22A3LS72KSpNWbka0RGeLW vfHJrUbDsKroCmTxe1wyBSoPYA+NgvED+pCnW6ue8y1/9huYTCxp7p6fNrGFUOr4 yd9OdRI7Jo66M4EChIlDKrsg9nDBhVwtk2UDVB7I7R/EdwUB7JILB2qXxhJrfDgE WMBEEXQLzwxrqgLTMHjyUAmaHUUKZxRKTDzz6BaWvF09eOeYoQKRKKwiGyW9bQXD QC4KZcV8Culz97nevi5ZHVAlNQeFs0y2xDXni87lVuH2cwyCi99gvXR8OWUl6Knm HAEQwVEl4RDt0oyHC0/bjYA6HA5EgkzLOv/64evH9vfX4UWRiiKJRcvBiGoTN9lA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedruddukedgudduvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecufghrlhcuvffnffculdejtddmnecujfgurhepgf gtjgffuffhvffksehtqhertddttdejnecuhfhrohhmpedfffgrnhhivghlucgiuhdfuceo ugiguhesugiguhhuuhdrgiihiieqnecukfhppeduieefrdduudegrddufedvrdegnecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepugiguhesugig uhhuuhdrgiihii X-ME-Proxy: Received: from localhost (unknown [163.114.132.4]) by mail.messagingengine.com (Postfix) with ESMTPA id E6F153280065; Mon, 9 Mar 2020 14:21:33 -0400 (EDT) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Originalfrom: "Joe Perches" Original: =?utf-8?q?On_Thu,_2020-03-05_at_13:16_-0800,_Daniel_Xu_wrote: =0D=0A>_It's?= =?utf-8?q?_not_really_necessary_to_have_contiguous_physical_memory_for_xa?= =?utf-8?q?ttr=0D=0A>_values._We_no_longer_need_to_worry_about_higher_orde?= =?utf-8?q?r_allocations=0D=0A>_failing_with_kvmalloc,_especially_because_?= =?utf-8?q?the_xattr_size_limit_is_at=0D=0A>_64K.=0D=0A=0D=0ASo_why_use_vm?= =?utf-8?q?alloc_memory_at_all=3F=0D=0A=0D=0A>_diff_--git_a/fs/xattr.c_b/f?= =?utf-8?q?s/xattr.c=0D=0A']=0D=0A>_@@_-817,7_+817,7_@@_struct_simple=5Fxa?= =?utf-8?q?ttr_*simple=5Fxattr=5Falloc(const_void_*value,_size=5Ft_size)?= =?utf-8?q?=0D=0A>__=09if_(len_<_sizeof(*new=5Fxattr))=0D=0A>__=09=09retur?= =?utf-8?q?n_NULL;=0D=0A>__=0D=0A>_-=09new=5Fxattr_=3D_kmalloc(len,_GFP=5F?= =?utf-8?q?KERNEL);=0D=0A>_+=09new=5Fxattr_=3D_kvmalloc(len,_GFP=5FKERNEL)?= =?utf-8?q?;=0D=0A=0D=0AWhy_is_this_sensible=3F=0D=0Avmalloc_memory_is_a_m?= =?utf-8?q?uch_more_limited_resource.=0D=0A=0D=0AAlso,_it_seems_as_if_the_?= =?utf-8?q?function_should_set=0D=0Anew=5Fxattr->name_to_NULL_before_the_r?= =?utf-8?q?eturn.=0D=0A=0D=0A=0D=0A?= In-Reply-To: <58c6e6dafabea52e5b030d18b83c13e4f43ab8e3.camel@perches.com> Originaldate: Fri Mar 6, 2020 at 12:49 AM Date: Mon, 09 Mar 2020 11:21:33 -0700 Cc: , , , Subject: Re: [PATCH v2 1/4] kernfs: kvmalloc xattr value instead of kmalloc From: "Daniel Xu" To: "Joe Perches" , , , , Message-Id: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Joe, On Fri Mar 6, 2020 at 12:49 AM, Joe Perches wrote: > On Thu, 2020-03-05 at 13:16 -0800, Daniel Xu wrote: > > It's not really necessary to have contiguous physical memory for xattr > > values. We no longer need to worry about higher order allocations > > failing with kvmalloc, especially because the xattr size limit is at > > 64K. > >=20 > So why use vmalloc memory at all? > >=20 > > diff --git a/fs/xattr.c b/fs/xattr.c > '] > > @@ -817,7 +817,7 @@ struct simple_xattr *simple_xattr_alloc(const void = *value, size_t size) > > if (len < sizeof(*new_xattr)) > > return NULL; > > =20 > > - new_xattr =3D kmalloc(len, GFP_KERNEL); > > + new_xattr =3D kvmalloc(len, GFP_KERNEL); > >=20 > Why is this sensible? > vmalloc memory is a much more limited resource. What would be the alternative? As Greg said, contiguous memory should be more scarce. > Also, it seems as if the function should set > new_xattr->name to NULL before the return. > Will add and send in a different patch. Thanks, Daniel