From patchwork Tue May 8 08:26:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Weinberger X-Patchwork-Id: 157641 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7496CB6FC2 for ; Tue, 8 May 2012 18:30:49 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SRfl1-0008VU-GR; Tue, 08 May 2012 08:26:55 +0000 Received: from a.ns.miles-group.at ([95.130.255.143] helo=radon.swed.at) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SRfky-0008Um-7w for linux-mtd@lists.infradead.org; Tue, 08 May 2012 08:26:52 +0000 Received: (qmail 25435 invoked by uid 89); 8 May 2012 08:26:51 -0000 Received: by simscan 1.3.1 ppid: 25427, pid: 25431, t: 0.1385s scanners: attach: 1.3.1 clamav: 0.96.5/m:53 Received: from unknown (HELO raccoon.haslach.nod.at) (richard@nod.at@178.191.109.36) by radon.swed.at with ESMTPA; 8 May 2012 08:26:50 -0000 From: Richard Weinberger To: linux-mtd@lists.infradead.org Subject: [PATCH] UBI: Replace yield() with cond_resched() Date: Tue, 8 May 2012 10:26:42 +0200 Message-Id: <1336465602-12627-1-git-send-email-richard@nod.at> X-Mailer: git-send-email 1.7.7.3 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: peterz@infradead.org, Richard Weinberger , dwmw2@infradead.org, linux-kernel@vger.kernel.org, dedekind1@gmail.com X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The comment above yield()'s definition says: * If you want to use yield() to wait for something, use wait_event(). * If you want to use yield() to be 'nice' for others, use cond_resched(). * If you still want to use yield(), do not! The yield() usage of UBI really looks like the "be nice for others" case, so use cond_resched(). Signed-off-by: Richard Weinberger CC: peterz@infradead.org --- drivers/mtd/ubi/io.c | 6 +++--- drivers/mtd/ubi/wl.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c index 43f1a00..a125ef6 100644 --- a/drivers/mtd/ubi/io.c +++ b/drivers/mtd/ubi/io.c @@ -192,7 +192,7 @@ retry: dbg_io("error %d%s while reading %d bytes from PEB " "%d:%d, read only %zd bytes, retry", err, errstr, len, pnum, offset, read); - yield(); + cond_resched(); goto retry; } @@ -366,7 +366,7 @@ retry: if (retries++ < UBI_IO_RETRIES) { dbg_io("error %d while erasing PEB %d, retry", err, pnum); - yield(); + cond_resched(); goto retry; } ubi_err("cannot erase PEB %d, error %d", pnum, err); @@ -384,7 +384,7 @@ retry: if (ei.state == MTD_ERASE_FAILED) { if (retries++ < UBI_IO_RETRIES) { dbg_io("error while erasing PEB %d, retry", pnum); - yield(); + cond_resched(); goto retry; } ubi_err("cannot erase PEB %d", pnum); diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index 7c1a9bf..f2f9056 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c @@ -1243,7 +1243,7 @@ retry: */ spin_unlock(&ubi->wl_lock); dbg_wl("the PEB %d is not in proper tree, retry", pnum); - yield(); + cond_resched(); goto retry; }