Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1142898rwb; Tue, 27 Sep 2022 08:59:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4BOYp3CLZYfaCjlv6ZThy45R5DJvkG5nbDs7QjtvuIB2aMerUNroUqB/dXde2bCcXjLA/Y X-Received: by 2002:a50:eb05:0:b0:457:c6f5:5f65 with SMTP id y5-20020a50eb05000000b00457c6f55f65mr2429926edp.311.1664294341361; Tue, 27 Sep 2022 08:59:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664294341; cv=none; d=google.com; s=arc-20160816; b=iW4efCYK8FhvehWr42ovYF9+D722YHQlqI92ko/8r1ZuPQSvTzMMs6BlWDTWZ+KOV3 9DLD3Cf2GuZK9wKgzUj4HJMrFCrdIYIySNJsuXdbQk6gnNECrCL44rGX19FYkDmuFx5C Z+sDTFvDgrSLxOSOFX/ZmxptVVR19dMBDBWosD5PIrQUDtjZ+CWSyhQjLdYSNZCwn2pf Vvm5i+zo2KC72vtDHi2tY7/9k4LT22cW3VRyrvusXXUmIwWAQZleiFMeXFZI7BhjVeiE 16QUaQ3hEB/Skupgg2P/Kd43gvh4KABTJ2/WCu1g+cjuJq6sNfNqO15SU0iINUbkJfjD r6Hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=RGfTD4NBOLWMCkradB21iOUt0wxo832XK6CrqAqR2GY=; b=uEQQonHk4sor3pO3DWIZwdrxU2+TMm3eHN6/NLju/O2Rtmk5ByrcgxE8fPHmt4M4vC 4Uc4kOpUyIy4qQZvQrceYVruvxomn9/Il33Guq8hbLS8GRlpcEGqJqqapJXMYkfL176Q ehurZPkiCrH9S1cDNCLidWijktiVwESjVuX/zpTibYOPNPlRTbXGWF+ZmUZICFljNGHu H3zKrE78RzSr4fFqFB8VKXokrQPr/b5PHklZnVIRVUCn0mgE/TDmtW3MHWUHmA1bNAYv /ew5CiVbeWtNbEwx5aOBJOp1kweRqhz5eWKqHDgKRKZIwoWXbOYnv5LpAK3Lz7YubbMQ w3EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FRmqHXAn; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i32-20020a0564020f2000b00457d6203a0bsi376306eda.62.2022.09.27.08.58.35; Tue, 27 Sep 2022 08:59:01 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FRmqHXAn; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232516AbiI0PrC (ORCPT + 99 others); Tue, 27 Sep 2022 11:47:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232526AbiI0Pqi (ORCPT ); Tue, 27 Sep 2022 11:46:38 -0400 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 586BD25C2; Tue, 27 Sep 2022 08:43:23 -0700 (PDT) Received: by mail-io1-xd2f.google.com with SMTP id p202so8040813iod.6; Tue, 27 Sep 2022 08:43:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=RGfTD4NBOLWMCkradB21iOUt0wxo832XK6CrqAqR2GY=; b=FRmqHXAnA0Nlr7CuCFa/vix9iR1N23MYD3UAIyxIrWl3zMGywdKlliuS+7RvdJLp0s AOp4ynTOO5Dw1uoCO2t6YKv+AEutCv6Qm+TF2dlX/Rsc94zPvoiWdWDWfbhx48QrnVua B8Rdk5ZI5hVFb09DwXb3dvLS5z47+wzRTvQfCcN+2nEDjnHjirh9TekDHGXtzlxPepYQ hd+OhA9reVu234odrbQBh/Hbt20ydVYftwxy6YDwqJtl9pGAqXlXC6cog6jNnHp357Ze b6aLaGVCgQiotev4H0qmTYFG/U8MfgaJkw3rPXOo/5XGR8IyHUeWxnyj77iepW02vFmi 6E+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=RGfTD4NBOLWMCkradB21iOUt0wxo832XK6CrqAqR2GY=; b=WcdzLwt2d3yxCh040luQVdL4aaLsnfJKKCuuXiwTY3CzrMFpgkh6jodYWdGHW00Ho1 s+8xwvQZw1qpl32VFgA8vvX6nFNnodpsf2iyC+GDjh6zMYt5bK9fe8Giohj8Nau/yZhe cwZXepwTmzBFhGyZGExujgrMK0ej+YtSuOD1pr8XXq57o5RXlz8OX+u8TRUZ2UNqpj57 /h2QByxHtDJLIqv20Fd0TSLBTvPXIljMvqvxE9L79xlrOL6oecq2pB5CWnXp5q2jCd6A 78jg9tidCtJnhs2GdpxWNf6JirsMVYBn6G1w6VMJ4O6jkjMJYunbQQ3cuSXQbN2u5t2L OZYQ== X-Gm-Message-State: ACrzQf2XW653PJJJ0mQoTtn/bDCw6zbNwHTqX2ya7sexjRrfcFFX21B6 4P2rtjbfYThAXW8RBrSw3eKvpxKDoVWkL+gtU+Y= X-Received: by 2002:a05:6638:4115:b0:35a:2729:fc6b with SMTP id ay21-20020a056638411500b0035a2729fc6bmr15445039jab.264.1664293402668; Tue, 27 Sep 2022 08:43:22 -0700 (PDT) MIME-Version: 1.0 References: <20220927131518.30000-1-ojeda@kernel.org> <20220927131518.30000-13-ojeda@kernel.org> In-Reply-To: From: Miguel Ojeda Date: Tue, 27 Sep 2022 17:43:11 +0200 Message-ID: Subject: Re: [PATCH v10 12/27] rust: add `kernel` crate To: Greg Kroah-Hartman Cc: Miguel Ojeda , Linus Torvalds , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, patches@lists.linux.dev, Jarkko Sakkinen , Wedson Almeida Filho , Alex Gaynor , Geoffrey Thomas , Finn Behrens , Adam Bratschi-Kaye , Sven Van Asbroeck , Gary Guo , Boris-Chengbiao Zhou , Boqun Feng , Fox Chen , Viktor Garske , Dariusz Sosnowski , =?UTF-8?Q?L=C3=A9o_Lanteri_Thauvin?= , Niklas Mohrin , Milan Landaverde , Morgan Bartlett , Maciej Falkowski , =?UTF-8?B?TsOhbmRvciBJc3R2w6FuIEtyw6Fjc2Vy?= , David Gow , John Baublitz , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 Tue, Sep 27, 2022 at 5:22 PM Greg Kroah-Hartman wrote: > > This feels "odd" to me. Why not just use __kmalloc() instead of > krealloc()? I think that will get you the same kasan tracking, and > should be a tiny bit faster (1-2 less function calls). > > I guess it probably doesn't matter right now, just curious, and not a > big deal at all. Yeah, nowadays I think a "C helper" could have been used instead. > You'll be adding other error values here over time, right? Indeed, I removed all the ones we didn't use in v8 to reduce it a bit more. Sorry for the confusion! :) > What about functions that do have return functions of: > >= 0 number of bytes read/written/consumed/whatever > < 0 error code > > Would that use Result or Error as a type? Or is it best just to not try > to model that mess in Rust calls? :) `Result`, i.e. the "number of bytes" part would go in the `Ok` variant and the "error code" in the `Err` variant. The benefit is that then you have to handle them "separately", i.e. you cannot confuse the number of bytes for the error code by mistake, or vice versa. > In the long run, using "raw" print macros like this is usually not the > thing to do. Drivers always have a device to reference the message to, > and other things like filesystems and subsystems have a prefix to use as > well. > > Hopefully not many will use these as-is and we can wrap them properly > later on. Definitely, we will have e.g. the `dev_*!` ones: https://github.com/Rust-for-Linux/linux/blob/fcad53ca9071c7bf6a412640a82e679bad6d1cd4/rust/kernel/device.rs#L479-L502 > Anyway, all looks sane to me, sorry for the noise: > > Reviewed-by: Greg Kroah-Hartman Thanks a lot for taking a look! Cheers, Miguel