Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755684Ab3IBG0r (ORCPT ); Mon, 2 Sep 2013 02:26:47 -0400 Received: from mail-lb0-f176.google.com ([209.85.217.176]:56541 "EHLO mail-lb0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754205Ab3IBG0q (ORCPT ); Mon, 2 Sep 2013 02:26:46 -0400 MIME-Version: 1.0 Date: Mon, 2 Sep 2013 14:26:45 +0800 Message-ID: Subject: Question regarding list_for_each_entry_safe usage in move_one_task From: Lei Wen To: Peter Zijlstra , Ingo Molnar , mingo@redhat.com, leiwen@marvell.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1147 Lines: 30 Hi Peter, I find one list API usage may not be correct in current fair.c code. In move_one_task function, it may iterate through whole cfs_tasks list to get one task to move. But in dequeue_task(), it would delete one task node from list without the lock protection. So that we could see from list_for_each_entry_safe API definitoin: #define list_for_each_entry_safe(pos, n, head, member) \ for (pos = list_entry((head)->next, typeof(*pos), member), \ n = list_entry(pos->member.next, typeof(*pos), member); \ &pos->member != (head); \ pos = n, n = list_entry(n->member.next, typeof(*n), member)) As this task node may be listed in the middle of this queue chain, it may lead to error of searching for the next node when iterating. Would this be possible to happen? Please help to comment it. Thanks, Lei -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/