Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp457573pxm; Wed, 2 Mar 2022 01:51:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+eIS95D6HjNHEQ1iuwU8wf6T/3Em52gnXy/+C1CqT83LJMy5em60UMcqJSa5HtoLAtA1g X-Received: by 2002:a17:90a:9292:b0:1bd:1bf0:30e6 with SMTP id n18-20020a17090a929200b001bd1bf030e6mr8979233pjo.73.1646214714087; Wed, 02 Mar 2022 01:51:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646214714; cv=none; d=google.com; s=arc-20160816; b=rdNSAW0lJypbA51DkmHryz8XCq2bTBYodyAfSq6wFPO7XhUg7fZ0vKSj9+qDqy6E9i cCDjMMjyJGvMM2KSpOFr9iQmFOSnpMN0H0cugFFimy6BTyamtBKhoF8JC8XeHLO9Nosk Ccx31r4i8L3Q2V78rxnFyORlimwo5n2SQtDp9PxVNgJj6TOf110erJIpGPuAJbkxSyrV sCkEN+SV3BMg16kZ09LDT+XsuPoB/i2O8ncC/8ZPRqka+BZgSYJgnH1Y/55pLe2wiqtp SSSWZ2alwZWEaHfI2K6J6Uuj4rSlFsnBFLodf0/jEgx0UXUV/AKbHuXVSb7zJhhxvVti sxCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id; bh=oTKI+/50Sxy7l8191LmY4hSgW0h+SsYk9lQsMX9/FGk=; b=tcDIu+PZ1cYhz3jBI+4qMC+YdZ6cl2Mu8ZT+FLwa+CoGlSw2VL1bowfDDXLp7Ll9nJ CZyWd6qAr/x8ojbv5KjjKw3kokjlBzm8fqDnR88uup6sgBhMPprYT6yYIdvhPh99XD4O PKGqo4i+w8rJk8nytFzwcIwroCFIwAMHBWkJ29/KJ6+nmkdNf53EAWCYVuHXeMdbhaxd Dd1HOEZzrLid6bCKU+Jj/1dg7SyyLJHnUE3VpTdAaMcznBrNtjPsHHBOjfe1MDybUouK /l4IK/F8yC5KHlLelN9Y/El5me4bkdiwAJjEwfbUVl6U+MyWYBEsPPnVVLkytQW9pvUE A/XQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u32-20020a056a0009a000b004cd4e75b40csi15062285pfg.29.2022.03.02.01.51.38; Wed, 02 Mar 2022 01:51:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239716AbiCBGi5 (ORCPT + 99 others); Wed, 2 Mar 2022 01:38:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231644AbiCBGi4 (ORCPT ); Wed, 2 Mar 2022 01:38:56 -0500 Received: from out30-44.freemail.mail.aliyun.com (out30-44.freemail.mail.aliyun.com [115.124.30.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F46013DDE; Tue, 1 Mar 2022 22:38:13 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=haoxu@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0V61CwrZ_1646203089; Received: from 30.226.12.26(mailfrom:haoxu@linux.alibaba.com fp:SMTPD_---0V61CwrZ_1646203089) by smtp.aliyun-inc.com(127.0.0.1); Wed, 02 Mar 2022 14:38:10 +0800 Message-ID: <81a915d3-cf5f-a884-4649-704a5cf26835@linux.alibaba.com> Date: Wed, 2 Mar 2022 14:38:09 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v4 2/2] io_uring: Add support for napi_busy_poll Content-Language: en-US From: Hao Xu To: Olivier Langlois , Jens Axboe , Pavel Begunkov Cc: io-uring , linux-kernel References: <29bad95d-06f8-ea7c-29fe-81e52823c90a@linux.alibaba.com> <4f01857ca757ab4f0995420e6b1a6e3668a40da5.camel@trillion01.com> <4af380e8-796b-2dd6-4ebc-e40e7fa51ce1@linux.alibaba.com> In-Reply-To: <4af380e8-796b-2dd6-4ebc-e40e7fa51ce1@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/2/22 14:27, Hao Xu wrote: > > On 3/2/22 04:06, Olivier Langlois wrote: >> On Wed, 2022-03-02 at 02:31 +0800, Hao Xu wrote: >>>> +       ne = kmalloc(sizeof(*ne), GFP_NOWAIT); >>>> +       if (!ne) >>>> +               goto out; >>> IMHO, we need to handle -ENOMEM here, I cut off the error handling >>> when >>> >>> I did the quick coding. Sorry for misleading. >> If you are correct, I would be shocked about this. >> >> I did return in my 'Linux Device Drivers' book and nowhere it is >> mentionned that the kmalloc() can return something else than a pointer >> >> No mention at all about the return value >> >> in man page: >> https://www.kernel.org/doc/htmldocs/kernel-api/API-kmalloc.html >> API doc: >> >> https://www.kernel.org/doc/html/latest/core-api/mm-api.html?highlight=kmalloc#c.kmalloc >> >> >> header file: >> https://elixir.bootlin.com/linux/latest/source/include/linux/slab.h#L522 >> >> I did browse into the kmalloc code. There is a lot of paths to cover >> but from preliminary reading, it pretty much seems that kmalloc only >> returns a valid pointer or NULL... >> >> /** >>   * kmem_cache_alloc - Allocate an object >>   * @cachep: The cache to allocate from. >>   * @flags: See kmalloc(). >>   * >>   * Allocate an object from this cache.  The flags are only relevant >>   * if the cache has no available objects. >>   * >>   * Return: pointer to the new object or %NULL in case of error >>   */ >>     /** >>   * __do_kmalloc - allocate memory >>   * @size: how many bytes of memory are required. >>   * @flags: the type of memory to allocate (see kmalloc). >>   * @caller: function caller for debug tracking of the caller >>   * >>   * Return: pointer to the allocated memory or %NULL in case of error >>   */ >> >> I'll need someone else to confirm about possible kmalloc() return >> values with perhaps an example >> >> I am a bit skeptic that something special needs to be done here... >> >> Or perhaps you are suggesting that io_add_napi() returns an error code >> when allocation fails. > This is what I mean. >> >> as done here: >> https://elixir.bootlin.com/linux/latest/source/arch/alpha/kernel/core_marvel.c#L867 >> >> >> If that is what you suggest, what would this info do for the caller? >> >> IMHO, it wouldn't help in any way... > > Hmm, I'm not sure, you're probably right based on that ENOMEM here > shouldn't > > fail the arm poll, but we wanna do it, we can do something like what > we do for                             ^---but if we wanna do it