Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG REPORT] 未针对字符设备实现epoll item的删除功能 #1094

Open
fslongjin opened this issue Mar 10, 2025 · 7 comments
Open

[BUG REPORT] 未针对字符设备实现epoll item的删除功能 #1094

fslongjin opened this issue Mar 10, 2025 · 7 comments
Labels
bug-report 这是一个bug报告(如果确认是一个bug,请管理人员添加`bug` label)

Comments

@fslongjin
Copy link
Member

描述错误
对/dev/tty进行epoll,然后关闭epoll的时候会出现错误:

Image

在函数这里加一个日志信息,会发现设备信息是char device.
看代码发现在tty的kernel_ioctl方法里面添加了epoll_item,却没有找到任何删除epoll_item的地方。

请填写您的电脑的信息:

期望行为
epoll item能从tty里面删除。

一些思考

我发现这里对perf event inode、eventfd的处理都是downcast之后来做的。依我看,由于字符设备类型众多,在这一个个特判inode类型,然后进行remove_epoll的话不是那么合理。因此我认为,add_epoll、remove_epoll作为IndexNode的成员方法可能会更合理?

@GnoCiYeH @Godones @Samuka007

@fslongjin fslongjin added the bug-report 这是一个bug报告(如果确认是一个bug,请管理人员添加`bug` label) label Mar 10, 2025
@Godones
Copy link
Contributor

Godones commented Mar 10, 2025

我觉得可以

@GnoCiYeH
Copy link
Member

GnoCiYeH commented Mar 10, 2025

首先不是所有的inode类型都是可poll的,所以作为IndexNode的成员方法会有冗余。推荐的方式是定义一个PollableInode trait,可poll的inode只需要实现PollableInode即可,在PollableInode内部定义所有可poll inode需要的方法

@Godones
Copy link
Contributor

Godones commented Mar 10, 2025

既然不是所有的inode类型都是可poll的,那在IndexNode的默认实现中返回错误应该可以吧。不然再引入一个PollableInode的话,还是需要做判断?

@GnoCiYeH
Copy link
Member

GnoCiYeH commented Mar 10, 2025

我认为在IndexNode的默认实现中返回错误不是一个好的设计,返回错误的话同样也需要去判断这个错误类型。从功能性来说IndexNode承载的方法应该是所有inode通用方法,换个角度说,大多数inode都是不可poll的,却将将poll所依赖的方法加在通用IndexNode trait里面,以后这个trait只会越来越臃肿,多出很多无用的默认方法。

@Godones
Copy link
Contributor

Godones commented Mar 10, 2025

那如何在IndexNode和PollableInode之间转换呢?rust似乎不支持两个trait之间转换

@GnoCiYeH
Copy link
Member

或许可以Any+downcast实现?

@fslongjin
Copy link
Member Author

有道理,加个trait好些。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-report 这是一个bug报告(如果确认是一个bug,请管理人员添加`bug` label)
Projects
None yet
Development

No branches or pull requests

3 participants