But what if the caller is already holding the mmap_sem? Why force theacquire into this function? Since we are dealing with a semaphore/mutex,it is reasonable that other structures are protected by this, more workwill be done, and therefore put the weight of acquiring the sema in thecontrol of the caller where they can decide if more needs to be completed.

That was why I originally suggested creating a new rwsem_is_write_locked()function and basing a BUG_ON upon that.