From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757382AbdDFK1F (ORCPT ); Thu, 6 Apr 2017 06:27:05 -0400 Received: from merlin.infradead.org ([205.233.59.134]:36800 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755998AbdDFK06 (ORCPT ); Thu, 6 Apr 2017 06:26:58 -0400 Date: Thu, 6 Apr 2017 12:26:48 +0200 From: Peter Zijlstra To: Cong Wang Cc: Mike Galbraith , netdev , LKML Subject: Re: net/sched: latent livelock in dev_deactivate_many() due to yield() usage Message-ID: <20170406102648.4cycknb2jk5ftovh@hirez.programming.kicks-ass.net> References: <1491107321.13631.33.camel@gmx.de> <1491362429.4536.77.camel@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 04, 2017 at 10:25:19PM -0700, Cong Wang wrote: > On Tue, Apr 4, 2017 at 8:20 PM, Mike Galbraith wrote: > > - while (some_qdisc_is_busy(dev)) > > - yield(); > > + swait_event_timeout(swait, !some_qdisc_is_busy(dev), 1); > > } > > I don't see why this is an improvement even if I don't care about the > hardcoded timeout for now... Why the scheduler can make a better > decision with swait_event_timeout() than with cond_resched()? cond_resched() might be a no-op. and doing yield() will result in a priority inversion deadlock. Imagine the task doing yield() being the top priority (fifo99) task in the system. Then it will simply spin forever, not giving whatever task is required to make your condition true time to run.