On Sat Jan 31, 2026 at 12:58 AM CET, Gary Guo wrote:
> On Fri Jan 30, 2026 at 11:36 PM GMT, Timur Tabi wrote:
>> I think there might be a problem with this code that I don't know how to 
>> resolve.
>>
>> If CONFIG_NOVA_CORE_DEBUGFS=n, then DEBUGFS_ROOT is None, and so the 
>> .as_ref() will also be
>> none, and the .expect will cause a panic.  We don't want that.
>>
>> If I remove the .expect(), then log_parent becomes None, but then the 
>> .scope() won't compile.
>>
>> I could wrap the whole thing in #[cfg(CONFIG_NOVA_CORE_DEBUGFS)], but my 
>> understanding is that
>> the call to .scope() is necessary to ensure that LogBuffers is not dropped 
>> at the end of this
>> function.
>>
>> It seems like I'm going to need to do something like this in struct Gsp:
>>
>>      #[cfg(CONFIG_NOVA_CORE_DEBUGFS)]
>>      #[pin]
>>      logs: debugfs::Scope<LogBuffers>,
>>
>>      #[cfg(not(CONFIG_NOVA_CORE_DEBUGFS))]
>>      logs: LogBuffers,  // Just own them directly, no debugfs
>>
>> But the design of debugfs is to have it not care if debugfs is disabled.
>>
>> Any suggestions?
>
> I think the rationale behind current debugfs design is that when it is 
> disabled
> in its entirety, then all of the code are compiled out and you're leaved with
> ZST, so code don't have to care at all and you'll still have no codegen in the
> end.
>
> However, when debugfs is enabled, but CONFIG_NOVA_CORE_DEBUGFS=n, then using
> debugfs functionalities would *not* be compiled out (so, for the 
> `Dir::empty()`
> patch in the previous iteration, all of the debugging facility would still be
> around with CONFIG_DEBUG_FS=y and CONFIG_NOVA_CORE_DEBUGFS=n, which is not
> desirable).
>
> The straightforward solution is thus sprinkle 
> `#[cfg(CONFIG_NOVA_CORE_DEBUGFS)]`
> everywhere where debugfs is touched, which is non-ideal.
>
> One idea is to create types that look exactly like `Dir` but always ZST and
> no-op regardless whether CONFIG_DEBUG_FS is enabled... But that feel a bit..
> weird. Matthew, what do you think?

There is no need for CONFIG_NOVA_CORE_DEBUGFS in the first place. The only
Kconfig we need is for retaining the GSP log buffers after driver unbind.

Reply via email to