On Thu, Mar 20, 2025 at 06:58:04PM -0700, Jon Pan-Doh wrote: > Spammy devices can flood kernel logs with AER errors and slow/stall > execution. Add per-device ratelimits for AER correctable and uncorrectable > errors that use the kernel defaults (10 per 5s). > +static bool aer_ratelimited(struct pci_dev *dev, unsigned int severity) > +{ > + struct ratelimit_state *ratelimit; > + > + if (severity == AER_CORRECTABLE) > + ratelimit = &dev->aer_report->cor_log_ratelimit; > + else > + ratelimit = &dev->aer_report->uncor_log_ratelimit; > + > + return !__ratelimit(ratelimit); > +} I found the __ratelimit() return values a little confusing (1 == print the message, 0 == don't print), so this is appealing because it's less confusing by itself. But I think we should name this "aer_ratelimit()" and return the result of __ratelimit() without inverting it so it works the same way as __ratelimit() and similar wrappers like ata_ratelimit(), net_ratelimit(), drbd_ratelimit().