Received: by 2002:a05:7412:d024:b0:f9:90c9:de9f with SMTP id bd36csp86516rdb; Wed, 20 Dec 2023 07:02:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IH9R478BAgUDf+vd8vHQ+ctFajmaMsQtpQ/R13t40SYHURTDV5BAS2neK0qgrRgNqAUqCyo X-Received: by 2002:a17:906:739d:b0:a23:4a31:958a with SMTP id f29-20020a170906739d00b00a234a31958amr2911235ejl.63.1703084533429; Wed, 20 Dec 2023 07:02:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703084533; cv=none; d=google.com; s=arc-20160816; b=uCCvINDolko8DWtghOYnikEUe72l/tQyVvh7m0socG3+iX8XDLTN0N6aSegMP3CSn2 FYfvCmD5QJXj/gutp2TQLMHZLiKmSRdq0cVm3RlGuXQDICEuaQZybDr8ppz6WpIS9DrJ azHMIpWZEDLrGPXf0ZUT30q0ICeoy5Ih7hHjkdmddmfjJfz9IUQ4WQha4MwcLOSB/+RN sS9cS26DrBGBn71NTVAR2q7Pgg2vpf2oPl1WgGbapFb5LnCpnk+IjTdhTCM0VUhfc2Ki kXVzS+0Bf3F4902UmVUmmDlTahlOMf+M21LH+tWfElOx17WyhwnPyKbNVyRAkoKDUhPW SMNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=organization:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date; bh=++0QQgYEuGiNy652xeLmSalmM0HqfTsNZ30EQiVODpY=; fh=BiTih3HBn05OJvpBeKJCJhFgvirybBPBq65CdTV6sMo=; b=XVI/FKGWEqn+dm6cfT7YEI6gS3ljK2LAntJrmMzbl2lwyT8TXJ6IHBPkPlp5LlYqtK 3ppUbRPCy/HxcMQ3Bfg/HAQGu0tUy9pMol3z6TSXVsAmUH5PzKb+zXxnFZgIQ3kTs3iH Ihy0AupqeODgYPbpasO8z4PQajNI/fQxFA/1XsG3XfI+3P/jCP4LlFu3oPafvAsOdxqB g0Vp+GVMoO9XsE4Pp3U7FYagN7aaFVb70/YR/veoXq71x/CTRNNEuEA0c5gQRbXJPGX8 hFWjVj1UD0gCzoTtakB7f1ghPiBr0OXhQcoUmgG2yaNFyK4i/WMt1qvGtWa7Ym3unvvh Ioyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-7110-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7110-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id oy2-20020a170907104200b00a23645fc93asi2294489ejb.886.2023.12.20.07.02.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 07:02:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7110-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-7110-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7110-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 1075D1F23770 for ; Wed, 20 Dec 2023 15:02:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6E21A3E467; Wed, 20 Dec 2023 15:02:06 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7B4F3D97C; Wed, 20 Dec 2023 15:02:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=kernel.org X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="3044485" X-IronPort-AV: E=Sophos;i="6.04,291,1695711600"; d="scan'208";a="3044485" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2023 07:02:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="920005433" X-IronPort-AV: E=Sophos;i="6.04,291,1695711600"; d="scan'208";a="920005433" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga001.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2023 07:02:02 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.97) (envelope-from ) id 1rFy1q-00000007ZA3-1w1S; Wed, 20 Dec 2023 16:58:34 +0200 Date: Wed, 20 Dec 2023 16:58:34 +0200 From: Andy Shevchenko To: Kent Gibson Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, brgl@bgdev.pl, linus.walleij@linaro.org Subject: Re: [PATCH 2/4] gpiolib: cdev: allocate linereq using kvzalloc() Message-ID: References: <20231220015106.16732-1-warthog618@gmail.com> <20231220015106.16732-3-warthog618@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo On Wed, Dec 20, 2023 at 10:53:07PM +0800, Kent Gibson wrote: > On Wed, Dec 20, 2023 at 04:30:24PM +0200, Andy Shevchenko wrote: > > On Wed, Dec 20, 2023 at 09:51:04AM +0800, Kent Gibson wrote: > > > The size of struct linereq may exceed a page, so allocate space for > > > it using kvzalloc() instead of kzalloc(). > > > > It might be this needs a bit of elaboration. The kmalloc() tries to allocate > > a contiguous (in physical address space) chunk of memory and with fragmented > > memory it might be not possible. So the above issue might (rarely) happen. > > In most cases the call to kmalloc() will succeed. > > For sure, the kzalloc() generally works - or we wouldn't've gotten this > far as tests with MAX_LINES would've been failing. > We are targetting a very niche failure mode here. > > The size allocated can only be determined at runtime, may be more or > less than a page, and we don't care whether the physical memory allocated > is contiguous. > As such kvzalloc() is the appropriate allocator. > > Are you suggesting repeating the relevant sections of the > kmalloc/vmalloc() documentation or Memory Allocation Guide as part of the > checkin comment? I suggesting to make clear in the commit message that: - there is no bug per se with the code logic (i.o.w. there is no issue to have allocations bigger than one page) - this is very rarely case when it might be a problem You can also put a reference to the documentation, if you wish. This should be harmless and adding not more than a line into the commit message (or even as a Link: tag to the HTML variant of it). -- With Best Regards, Andy Shevchenko