On Jun 15, 2015 11:43 AM, "Andrea Arcangeli" <aarcange@redhat.com> wrote:
>
> Several times I got very hardly reproducible bugs noticed purely
> because of BUG_ON (not VM_BUG_ON)

Feel free to use them while developing. Don't send me patches with your broken debug code, though.

For users, a dead machine means that it is less likely you will ever get a bug report. People set "reboot on oops", and when running X is not always something that can be seen anyway. They'll just see a rebooting or a dead machine, and not send you any debug output.

This is not negotiable. Seriously. Get rid of the BUG_ON if you expect your patches to be merged mainline.

Also, even for debugging, using something like

    if (WARN_ON_ONCE(...))
         return -EINVAL;

is the right thing to do. Then you can unwind locks etc, and return cleanly, and you'll only get one warning rather than a stream of them etc.

So stop making excuses for your bad BUG_ON use. Do it in private where nobody can see your perversions, or do it right.

        Linus