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

follow-up fixups for atomic_t spinlocks #17611

Merged
merged 3 commits into from Sep 15, 2017

Conversation

chardan
Copy link
Contributor

@chardan chardan commented Sep 8, 2017

...tidy up a few things following the larger atomic_t commit. Thanks to @theanalyst for pointing out the missing spot!

@adamemerson Also patches some of the lock/RNG sites mentioned as a consequence of include/random.h being available.

Signed-off-by: Jesse Williamson jwilliamson@suse.de

Jesse Williamson added 3 commits September 8, 2017 09:59
Signed-off-by: Jesse Williamson <jwilliamson@suse.de>
Signed-off-by: Jesse Williamson <jwilliamson@suse.de>
Signed-off-by: Jesse Williamson <jwilliamson@suse.de>
@chardan chardan changed the title msg: fixup for atomic_t spinlocks in XioConnection follow-up fixups for atomic_t spinlocks Sep 8, 2017

return (0);
}

int XioConnection::CState::state_fail(Message* m, uint32_t flags)
{
if (! (flags & OP_FLAG_LOCKED))
pthread_spin_lock(&xcon->sp);
xcon->sp.lock();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to pass a 'locked' or 'unlocked' flag around, then it's better to just pass a reference to unique_lock

This might be more involved than you want to do right now, though.

On the other hand it's one of those "We're touching it doing cleanups anyway, we may as well get all the obvious, relevant ones done" sorta' things.

And since a flag stating whether something is locked and a lock are basically unique_lock except wandering around separately and not exception safe and not as idiomatic, I'd kind of like to replace use of the LOCKED flag with unique_lock.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, TBH I'm a bit sick today and thus taking the lazy route exactly as you surmised. ;-)
I also think the current implementation is probably more complicated than it needs to be. I'm ok taking time to Do The Right Thing(TM).


std::uniform_int_distribution<> dis(0, 1);
r = dis(random_engine);
r = ceph::util::generate_random_number(0, 1);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The power of libraries!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brought a tear to my eye, it did!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind to rename to gen_rand_number? ,to make consistent with rgw naming style (like https://github.com/ceph/ceph/blob/master/src/rgw/rgw_common.cc#L830)

@@ -160,7 +159,7 @@ void XioConnection::send_keepalive_or_ack(bool ack, const utime_t *tp)
{
/* If con is not in READY state, we need to queue the request */
if (cstate.session_state.read() != XioConnection::UP) {
pthread_spin_lock(&sp);
std::lock_guad<ceph::util::spinlock> lg(sp);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and that makes it worrisome that it compiled on both my local system and here... hmm...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with-xio is set to OFF by default, so cmake -DWITH_XIO=ON maybe?

@adamemerson
Copy link
Contributor

Also, you might want to use guardedly_lock/uniquely_lock, since they're merged in now.

(You don't HAVE to, but it'd save you having to type the template argument.)

@adamemerson
Copy link
Contributor

You just have to install Accelio and enable XIO. There's a README.

@chardan
Copy link
Contributor Author

chardan commented Sep 13, 2017

@adamemerson For general elucidation, is there a way to turn on such flags for these github builds?

@adamemerson
Copy link
Contributor

I don't think so.

If there is, I don't know about it.

@tchaikov tchaikov merged commit f18e0fe into ceph:master Sep 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants