Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp85069rdb; Mon, 18 Sep 2023 08:51:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHwFNYtMJr2mCb0TB4mHamrqkVxNHAFnnla0jbFJigRRrx5j3G1bqwvHsuTKZtUPICUwEoY X-Received: by 2002:a05:6a21:3389:b0:154:e054:d0d1 with SMTP id yy9-20020a056a21338900b00154e054d0d1mr2764089pzb.55.1695052287144; Mon, 18 Sep 2023 08:51:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695052287; cv=none; d=google.com; s=arc-20160816; b=ww+e075l4rJj5+oy0tTOj1h1dypODehMwozGbKsfHG/wpdWrCb6zbVZb2fxhFx47Bx Iai2HU0dd/QqnwSAv1qP+zeuYcdHSrot9DX+akVuft/kk7018lArNFp6U9EkSs70ZkRL +xqBLx2pjlOY722ECdslOdOYdkkm3Ip1thvySC3+PAxlgqNNlEf7zB3ZI5dmhiMw0hMl y7bffavTnuYGYPurT0Vmlim0nUK5BDsQYjGUGyAQpv904Nb34qq7RfkNyRXhPcca850P eD1IVWhd2t0YtWYoyH3d5bzgrG6QXPA6WSeLffzZj1QYzY4UFDHjRJUAZ7woN6V8nT8v elEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=ULOgXciKI1ha7dojcMBk6Pk8xfRXi1p1aWd2c7kI9So=; fh=D1uCIJnLkD44gi9xlY2Sn/VtNtQqTA/X4EC/8LgDNYA=; b=aiPjE03MVq5f55ammfk41TwMEUCU37pO9Sk18NBodjMxjtJXOHolO0k24eYNemP4pA CNOmJTyK0n60CQOa1Q3p7D72diMi5kDEqeheC+i+2QUxTHpwjy4R1Zqv6onpktE4/bWg yL99eE9awKEiUpfaoh5RouMB18qIrKzYhDOpJnN5joGKTyOJm49+h0lhM1uK5zMDXZd9 ZQsO2WuJ3lZoaK+gp/ctHlv4pybvqW6CFT15SJ3+csZyruYKUw1TwouhaQf8RwpLhrEq 0jD55gnbATcW2DojJtM1nl9p67Iz4f7JGtJwzlTeSiOulK2wx2mfAxQtRQXf2paBgnW0 /GYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id g192-20020a636bc9000000b00570979732e4si7946449pgc.392.2023.09.18.08.51.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 08:51:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id A54428078CA9; Mon, 18 Sep 2023 08:40:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229451AbjIRPkD convert rfc822-to-8bit (ORCPT + 99 others); Mon, 18 Sep 2023 11:40:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229556AbjIRPkB (ORCPT ); Mon, 18 Sep 2023 11:40:01 -0400 Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15EF7CF7; Mon, 18 Sep 2023 08:38:27 -0700 (PDT) Received: by mail-io1-f42.google.com with SMTP id ca18e2360f4ac-797ea09af91so27346439f.1; Mon, 18 Sep 2023 08:38:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695051237; x=1695656037; 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=MFE3SOieeOg7U2cFR/e5C3Az7OsuKy0SX2uLUyU2L9I=; b=KzuuybhJ/GNbrQIPkvQBI87ganokPfJJLFlAxD2NLdcVKjeo/WN1b+4L0ChCHPmS4q Aw1buvCKmBzRZuiNoZghTnjT2K6+8eG3UI9nJyxbLQSI9lJRZoJ3Le+Zoo3hnW3Rsw0q xEe8rGQnLRZRz4WjtM7bjSsqmhnxfgY+1+0kyyYZds2CmYihbTMKtoLaED51wFSK0ssH bRvRQZd34xmXoHCxABAjr+vVtRT4UgnJzqlug2XMBeP40KE9RCSnjMjBBW1Hl8yxPMn0 9L9Y49djGIXidd6D4e7iOAxq4rwMdqhUdcdrBMWznQili55qry75lTEsp8M/ncEMorIk 54cw== X-Gm-Message-State: AOJu0YzdhWNuViL9syYm3pblU/5o5I/u/lJq2zgdZO6NUhVSGFmjN7/c hVi3lDP0afWa+gNWPsPD8KN106yl3U9+mbBSPu3pvssurGc= X-Received: by 2002:a4a:d38e:0:b0:573:764b:3b8d with SMTP id i14-20020a4ad38e000000b00573764b3b8dmr8216476oos.0.1695049777925; Mon, 18 Sep 2023 08:09:37 -0700 (PDT) MIME-Version: 1.0 References: <20230918124117.187-1-guojinhui.liam@bytedance.com> In-Reply-To: <20230918124117.187-1-guojinhui.liam@bytedance.com> From: "Rafael J. Wysocki" Date: Mon, 18 Sep 2023 17:09:27 +0200 Message-ID: Subject: Re: [PATCH] driver core: platform: set numa_node before platform_add_device() To: Jinhui Guo Cc: rafael@kernel.org, gregkh@linuxfoundation.org, lenb@kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, lizefan.x@bytedance.com, lkp@intel.com, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:40:13 -0700 (PDT) X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email On Mon, Sep 18, 2023 at 2:41 PM Jinhui Guo wrote: > > On Mon, 18 Sep 2023 12:30:58 +0200, Rafael J. Wysocki wrote: > > On Thu, Sep 14, 2023 at 11:32 PM Jinhui Guo > > wrote: > > > > > > platform_add_device() > > > > According to "git grep" this function is not present in 6.6-rc2. > > > > If you mean platform_device_add(), please update the patch subject and > > changelog accordingly. > > > > This is my mistake, the function name was written wrong. > I will fix it in the next patch. > > > > creates the numa_node attribute of sysfs according > > > to whether dev_to_node(dev) is equal to NUMA_NO_NODE. So set the numa node > > > of device before creating numa_node attribute of sysfs. > > > > It would be good to also say that this needs to be done in > > platform_device_register_full(), because that's where the platform > > device object is allocated. > > > > Thaks for your suggestion. I will modify my decription soon. > > > However, what about adding the NUMA node information to pdevinfo? It > > would be more straightforward to handle it then AFAICS. > > > > I have tried three potential solutions to fix the bug: > 1. The first one is what the current patch do. > > 2. Add a new function interface only for acpi_create_platform_device() call. > But the code will be a bit redundant. > > 3. Add an member "numa_node" in `struct platform_device_info`, just as what > `struct device` done: > > ``` > struct platform_device_info { > ...; > #ifdef CONFIG_NUMA > int numa_node; > #endif > ``` > > But not all the call to platform_device_register_full() would set numa_node, > and many of them use ` memset(&pdevinfo, 0, sizeof(pdevinfo));` to initialize > `struct platform_device_info`. It could initialize numa_node to zero and > result in wrong numa_node information in sysfs. Well, platform_device_register_full() need not take that value as the numa node number directly. It may, for example, take the number from pdevinfo, subtract 1 from it and use the result of that as the numa node number, if not negative.