Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp979651lqp; Fri, 22 Mar 2024 01:37:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU/LYoQRODYkDIfP6iGi3UA9Wt5xEiS5S/DUuO+KaJQebdaP03k1QfhFqz5PfZiXbqvtEFyVIhwRKJiKAD7YTGCLxsMHyyGBCJaXMJJTQ== X-Google-Smtp-Source: AGHT+IFNwqRNI4bhTQr+Fp3TSCxa/vwBTWQ5/sChjMcyDBwQ2KeMF85y17dwvP2E4FTk2dMyhcex X-Received: by 2002:a17:906:3481:b0:a46:7dc1:e4d1 with SMTP id g1-20020a170906348100b00a467dc1e4d1mr1122563ejb.73.1711096679503; Fri, 22 Mar 2024 01:37:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711096679; cv=pass; d=google.com; s=arc-20160816; b=MBIPKYrDOMiOgpsYuVFsP+2JVlynIx+EsAqBZ6rziPCzEB8Y5IJcOEp5Tvp+Lq7SCs MKZRUQ9HZ4o3F0CW7A+pKe807OPuocT320jMA2osyhcKnKqIDCHX17x1ZbXZXbRstUIL 43E7QK+T9tK9h47gZFhJUOK9kjfr1QA0/jhrI7WDEDt81kw+RoBLPhaktO1NZBBv1YU3 ga9e1ilYWdD9mT60XOZIx1u/moACXTc5KINf9W2saMCEzhItEV8vHqW4Js5B6+ytdGxa Zdak7RBHo3uAd8aeAOybzg311cBlzliu7Un93ZryDHIG+9El+SIPp5ibMBbNWbmjJ6pt MSew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=B+eEe2rJKYVCOSpsUyFR0aFEgGcdrU57l8z/qph+tmM=; fh=9OatH48L9grgrV5JDOw2rxHBc/staIyztKHpwtOxk5E=; b=g6Y9xpeiiLBbEbcN+hVQ01MTxqaINsvishy5rjY3gAW3er240CsGvY+Bj6GDQ+wS3c 9OBg2adWncAw0QrwACngkeC+YD6PDtDm9TxC3lwJXBA/Urv9eSCA/u3X9+ffXWxdDoyP dtI6/6h9QuO5oBY2YxRI9oe4X7ZBsW5BF8mvkA5oJQ4jzMAHAPeflG84sp1ghTLlItbj c89pBvkzqfmZpYVQUUhZuQ6VkLJFmFWPOkK/NH6c+seH2N8jsplM/zKqb/rDBUoEUpZw WUd7hIFtIN//ZQKA1GmtLXNEtJx5sdHY2KUS4IJh5fHDPcryy1e1pKAJbRQQnaGgswZs z2jw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=JHtyBQH6; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-111144-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111144-linux.lists.archive=gmail.com@vger.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 u23-20020a509517000000b00568d7b0a1dbsi696335eda.435.2024.03.22.01.37.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 01:37:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111144-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; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=JHtyBQH6; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-111144-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111144-linux.lists.archive=gmail.com@vger.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 13EE51F2105D for ; Fri, 22 Mar 2024 08:37:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 244423FBB1; Fri, 22 Mar 2024 08:35:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="JHtyBQH6" Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 CD0B83FB87; Fri, 22 Mar 2024 08:35:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711096518; cv=none; b=eRyvRm3Lycb7ApnXtvnIBjdesZVe7Opnefl2cWkj4NUEEdU7QIVpEgOM3Ur5C44um9ErReKVMzRQf9dVd4Jw/CtGMKrsi3K6kNJ0likACK3j3KuS8pSkreyT23GdLihKoH+kJ6TFoQ7P1pq5d6bXAfdrobhbBSXeXDFn7P/f0hQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711096518; c=relaxed/simple; bh=ubt8vwuXHMoPvm2FKiDUEHRj3q7PZZktUm1LKe+DoxQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Lvc1Lv4sF1vhyT5ijFDp1g1LX+3ydRGLLNpIW/oC/DgERrxxWSgim50IQFi44oDCqCSUEC5JeHJbGA+ZipO3s7Adr/U36F5xH1NzT2VDSGb/D+WmH3H+JQ9bhTA1RILUqcK0YBWHbXnmKAvcifrPd3es64PGIMXTHJYKe/gJU4g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=JHtyBQH6; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID: Sender:Reply-To:Content-ID:Content-Description; bh=B+eEe2rJKYVCOSpsUyFR0aFEgGcdrU57l8z/qph+tmM=; b=JHtyBQH6EX7GceqkO4taJJgxTp MHSM6Uqnw3YFlkvvhAiy3qbAR0vYz3MGRdxZmGg5/mdAUNTul1mWj09WvLulV1q1v69YEuYQIuXhn P+4q733Age1NYD6hfFWEFc0t+KuF9HA90D8+TcIfO/d9koXu4navByN+ZmWwMcqPO/i01Opbj0EBy WTuTwTFJ/dZm7bPQd8J/FD43zJbO6Y047A+sffZnE54IZNoZV5n9cCRmuC+yxOzAZwfnlJQq4pCoy ym665tUf6yqhhjtVMcCNHOKjEijyCNM6tDQWevVoSRf1chQmYyScxbzC4JT3i+oeKd+PzlolBJwMN 7ds5xwDA==; Received: from fpd2fa7e2a.ap.nuro.jp ([210.250.126.42] helo=[192.168.1.8]) by desiato.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rnaMZ-0000000EhCD-3xGY; Fri, 22 Mar 2024 08:34:56 +0000 Message-ID: <87f6365f-a40e-4606-baff-170cb8fc48f3@infradead.org> Date: Fri, 22 Mar 2024 17:34:45 +0900 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] powerpc: ps3: mark ps3_notification_device static for stack usage To: Geert Uytterhoeven , Arnd Bergmann Cc: Michael Ellerman , Nathan Chancellor , Paul Mackerras , Arnd Bergmann , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Nick Desaulniers , Bill Wendling , Justin Stitt , Kevin Hao , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev References: <20240320180333.151043-1-arnd@kernel.org> Content-Language: en-US From: Geoff Levand In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 3/21/24 17:32, Geert Uytterhoeven wrote: > --- a/arch/powerpc/platforms/ps3/device-init.c >> +++ b/arch/powerpc/platforms/ps3/device-init.c >> @@ -770,7 +770,7 @@ static struct task_struct *probe_task; >> >> static int ps3_probe_thread(void *data) >> { >> - struct ps3_notification_device dev; >> + static struct ps3_notification_device dev; >> int res; >> unsigned int irq; >> u64 lpar; > > Making it static increases kernel size for everyone. So I'd rather > allocate it dynamically. The thread already allocates a buffer, which > can be replaced at no cost by allocating a structure containing both > the ps3_notification_device and the buffer. Here's what I came up with. It builds for me without warnings. I haven't tested it yet. A review would be appreciated. diff --git a/arch/powerpc/platforms/ps3/device-init.c b/arch/powerpc/platforms/ps3/device-init.c index 878bc160246e..9bb44a6ccdaf 100644 --- a/arch/powerpc/platforms/ps3/device-init.c +++ b/arch/powerpc/platforms/ps3/device-init.c @@ -770,37 +770,48 @@ static struct task_struct *probe_task; static int ps3_probe_thread(void *data) { - struct ps3_notification_device dev; + struct ps3_probe_thread_local { + struct ps3_notification_device dev; + union { + char buf[512]; + struct ps3_notify_cmd notify_cmd; + struct ps3_notify_event notify_event; + }; + }; + struct ps3_probe_thread_local *local; + struct ps3_notification_device *dev; + struct ps3_notify_cmd *notify_cmd; + struct ps3_notify_event *notify_event; int res; unsigned int irq; u64 lpar; - void *buf; - struct ps3_notify_cmd *notify_cmd; - struct ps3_notify_event *notify_event; pr_debug(" -> %s:%u: kthread started\n", __func__, __LINE__); - buf = kzalloc(512, GFP_KERNEL); - if (!buf) + local = kzalloc(sizeof(local), GFP_KERNEL); + + if (!local) return -ENOMEM; - lpar = ps3_mm_phys_to_lpar(__pa(buf)); - notify_cmd = buf; - notify_event = buf; + dev = &local->dev; + notify_cmd = &local->notify_cmd; + notify_event = &local->notify_event; + + lpar = ps3_mm_phys_to_lpar(__pa(&local->notify_cmd)); /* dummy system bus device */ - dev.sbd.bus_id = (u64)data; - dev.sbd.dev_id = PS3_NOTIFICATION_DEV_ID; - dev.sbd.interrupt_id = PS3_NOTIFICATION_INTERRUPT_ID; + dev->sbd.bus_id = (u64)data; + dev->sbd.dev_id = PS3_NOTIFICATION_DEV_ID; + dev->sbd.interrupt_id = PS3_NOTIFICATION_INTERRUPT_ID; - res = lv1_open_device(dev.sbd.bus_id, dev.sbd.dev_id, 0); + res = lv1_open_device(dev->sbd.bus_id, dev->sbd.dev_id, 0); if (res) { pr_err("%s:%u: lv1_open_device failed %s\n", __func__, __LINE__, ps3_result(res)); goto fail_free; } - res = ps3_sb_event_receive_port_setup(&dev.sbd, PS3_BINDING_CPU_ANY, + res = ps3_sb_event_receive_port_setup(&dev->sbd, PS3_BINDING_CPU_ANY, &irq); if (res) { pr_err("%s:%u: ps3_sb_event_receive_port_setup failed %d\n", @@ -808,11 +819,11 @@ static int ps3_probe_thread(void *data) goto fail_close_device; } - spin_lock_init(&dev.lock); - rcuwait_init(&dev.wait); + spin_lock_init(&dev->lock); + rcuwait_init(&dev->wait); res = request_irq(irq, ps3_notification_interrupt, 0, - "ps3_notification", &dev); + "ps3_notification", &local->dev); if (res) { pr_err("%s:%u: request_irq failed %d\n", __func__, __LINE__, res); @@ -823,7 +834,7 @@ static int ps3_probe_thread(void *data) notify_cmd->operation_code = 0; /* must be zero */ notify_cmd->event_mask = 1UL << notify_region_probe; - res = ps3_notification_read_write(&dev, lpar, 1); + res = ps3_notification_read_write(&local->dev, lpar, 1); if (res) goto fail_free_irq; @@ -834,36 +845,36 @@ static int ps3_probe_thread(void *data) memset(notify_event, 0, sizeof(*notify_event)); - res = ps3_notification_read_write(&dev, lpar, 0); + res = ps3_notification_read_write(&local->dev, lpar, 0); if (res) break; pr_debug("%s:%u: notify event type 0x%llx bus id %llu dev id %llu" " type %llu port %llu\n", __func__, __LINE__, - notify_event->event_type, notify_event->bus_id, - notify_event->dev_id, notify_event->dev_type, - notify_event->dev_port); + notify_event->event_type, notify_event->bus_id, + notify_event->dev_id, notify_event->dev_type, + notify_event->dev_port); if (notify_event->event_type != notify_region_probe || - notify_event->bus_id != dev.sbd.bus_id) { + notify_event->bus_id != dev->sbd.bus_id) { pr_warn("%s:%u: bad notify_event: event %llu, dev_id %llu, dev_type %llu\n", __func__, __LINE__, notify_event->event_type, notify_event->dev_id, notify_event->dev_type); continue; } - ps3_find_and_add_device(dev.sbd.bus_id, notify_event->dev_id); + ps3_find_and_add_device(dev->sbd.bus_id, notify_event->dev_id); } while (!kthread_should_stop()); fail_free_irq: - free_irq(irq, &dev); + free_irq(irq, &local->dev); fail_sb_event_receive_port_destroy: - ps3_sb_event_receive_port_destroy(&dev.sbd, irq); + ps3_sb_event_receive_port_destroy(&dev->sbd, irq); fail_close_device: - lv1_close_device(dev.sbd.bus_id, dev.sbd.dev_id); + lv1_close_device(dev->sbd.bus_id, dev->sbd.dev_id); fail_free: - kfree(buf); + kfree(local); probe_task = NULL;