From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752228AbdLGIiY (ORCPT ); Thu, 7 Dec 2017 03:38:24 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:45783 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750981AbdLGIiX (ORCPT ); Thu, 7 Dec 2017 03:38:23 -0500 Date: Thu, 7 Dec 2017 09:38:20 +0100 From: Peter Zijlstra To: Rodrigo Siqueira Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Scheduler: Removed first parameter from prepare_lock_switch Message-ID: <20171207083820.tpgeqcfoelnau637@hirez.programming.kicks-ass.net> References: <20171205140200.4guikhmagltvoehm@smtp.gmail.com> <20171206121437.g7wsnqhx6oyycyqf@hirez.programming.kicks-ass.net> <20171206235019.vvpx467magnuk25d@smtp.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171206235019.vvpx467magnuk25d@smtp.gmail.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 06, 2017 at 09:50:19PM -0200, Rodrigo Siqueira wrote: > > Yes, this is correct. However it had me looking at that code and pretty > > much everything else is completely wrong :-) > > > > That is, its functionally correct (probably), but the function name is > > not descriptive of what the function does and the comment is just plain > > wrong. > > > > Also, since both functions are only used in core.c we should probably > > move them there. > > I'm not sure I understood it completely. What do you mean for wrong? Will > CONFIG_SMP a meaningless check here? So the actual effective code is ok; including the #ifdef for SMP. But the comment is complete nonsense. Look at the comments: - in finish_lock_switch() doing smp_store_release() - before try_to_wake_up() describing migration/blocking - in try_to_wake_up() doing smp_cond_load_acquire(). To get a feeling for what on_cpu actually does; it doesn't have anything much to do with SMP rebalancing code from interrupt contexts (although that too still cares through can_migrate_task() <- task_running()). > How about moving 'prepare_lock_switch' code from sched.h to prepare_task_switch > in core.c? With a rename; yes. Maybe something like 'acquire_task()' would do. Then split the smp_store_release() out from finish_lock_switch() and call it release_task(), and place is near the new acquire_task() function -- don't forget to update all comments referring to finish_lock_switch(). This then leaves the actual rq->lock fiddling in finish_lock_switch(); and that whole function too can be moved to core.c, somewhere near finish_task_switch() I think.