From patchwork Thu Nov 20 07:35:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Dongdong X-Patchwork-Id: 5346531 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C2F3C9F387 for ; Thu, 20 Nov 2014 08:15:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C6165201F5 for ; Thu, 20 Nov 2014 08:15:29 +0000 (UTC) Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D26C7201E4 for ; Thu, 20 Nov 2014 08:15:28 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id sAK8AuaD020030; Thu, 20 Nov 2014 03:10:57 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id sAK7HZGV005179 for ; Thu, 20 Nov 2014 02:17:35 -0500 Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.19]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sAK7HZO5021464; Thu, 20 Nov 2014 02:17:35 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [119.145.14.65]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sAK7HPla020180 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL); Thu, 20 Nov 2014 02:17:30 -0500 Received: from 172.24.2.119 (EHLO lggeml426-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CCQ23635; Thu, 20 Nov 2014 15:17:24 +0800 (CST) Received: from KernelMiner-T2285.huawei.com (10.107.197.189) by lggeml426-hub.china.huawei.com (10.72.61.36) with Microsoft SMTP Server id 14.3.158.1; Thu, 20 Nov 2014 15:17:17 +0800 From: Yao Dongdong To: , Date: Thu, 20 Nov 2014 07:35:40 +0000 Message-ID: <1416468940-8398-1-git-send-email-yaodongdong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.107.197.189] X-CFilter-Loop: Reflected X-RedHat-Spam-Score: -3.01 (BAYES_00, DCC_REPUT_00_12, RCVD_IN_DNSWL_LOW, SPF_PASS, T_RP_MATCHES_RCVD, URIBL_BLOCKED) 119.145.14.65 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.19 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Thu, 20 Nov 2014 03:10:56 -0500 Cc: lizefan@huawei.com, snitzer@redhat.com, dm-devel@redhat.com, linux-kernel@vger.kernel.org, agk@redhat.com Subject: [dm-devel] [PATCH] sched, cleanup, dm bufio: Replace dm_bufio_cond_resched with might_resched X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The judge of need_resched() before _cond_resched() in dm_bufio_cond_resched() is no need. Because _cond_resched() itself judges should_resched() which means need and can resched. In addition, might_resched() can do all these. Signed-off-by: Yao Dongdong --- drivers/md/dm-bufio.c | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c index afe7971..3660a24 100644 --- a/drivers/md/dm-bufio.c +++ b/drivers/md/dm-bufio.c @@ -186,19 +186,6 @@ static void dm_bufio_unlock(struct dm_bufio_client *c) mutex_unlock(&c->lock); } -/* - * FIXME Move to sched.h? - */ -#ifdef CONFIG_PREEMPT_VOLUNTARY -# define dm_bufio_cond_resched() \ -do { \ - if (unlikely(need_resched())) \ - _cond_resched(); \ -} while (0) -#else -# define dm_bufio_cond_resched() do { } while (0) -#endif - /*----------------------------------------------------------------*/ /* @@ -648,7 +635,7 @@ static void __flush_write_list(struct list_head *write_list) list_entry(write_list->next, struct dm_buffer, write_list); list_del(&b->write_list); submit_io(b, WRITE, b->block, write_endio); - dm_bufio_cond_resched(); + might_resched(); } blk_finish_plug(&plug); } @@ -687,7 +674,7 @@ static struct dm_buffer *__get_unclaimed_buffer(struct dm_bufio_client *c) __unlink_buffer(b); return b; } - dm_bufio_cond_resched(); + might_resched(); } list_for_each_entry_reverse(b, &c->lru[LIST_DIRTY], lru_list) { @@ -698,7 +685,7 @@ static struct dm_buffer *__get_unclaimed_buffer(struct dm_bufio_client *c) __unlink_buffer(b); return b; } - dm_bufio_cond_resched(); + might_resched(); } return NULL; @@ -830,7 +817,7 @@ static void __write_dirty_buffers_async(struct dm_bufio_client *c, int no_wait, return; __write_dirty_buffer(b, write_list); - dm_bufio_cond_resched(); + might_resched(); } } @@ -880,7 +867,7 @@ static void __check_watermark(struct dm_bufio_client *c, return; __free_buffer_wake(b); - dm_bufio_cond_resched(); + might_resched(); } if (c->n_buffers[LIST_DIRTY] > threshold_buffers) @@ -896,7 +883,7 @@ static struct dm_buffer *__find(struct dm_bufio_client *c, sector_t block) hlist_for_each_entry(b, &c->cache_hash[DM_BUFIO_HASH(block)], hash_list) { - dm_bufio_cond_resched(); + might_resched(); if (b->block == block) return b; } @@ -1090,7 +1077,7 @@ void dm_bufio_prefetch(struct dm_bufio_client *c, submit_io(b, READ, b->block, read_endio); dm_bufio_release(b); - dm_bufio_cond_resched(); + might_resched(); if (!n_blocks) goto flush_plug; @@ -1211,7 +1198,7 @@ again: !test_bit(B_WRITING, &b->state)) __relink_lru(b, LIST_CLEAN); - dm_bufio_cond_resched(); + might_resched(); /* * If we dropped the lock, the list is no longer consistent, @@ -1473,7 +1460,7 @@ static long __scan(struct dm_bufio_client *c, unsigned long nr_to_scan, freed += __cleanup_old_buffer(b, gfp_mask, 0); if (!--nr_to_scan) return freed; - dm_bufio_cond_resched(); + might_resched(); } } return freed; @@ -1704,11 +1691,11 @@ static void cleanup_old_buffers(void) struct dm_buffer, lru_list); if (!__cleanup_old_buffer(b, 0, max_age * HZ)) break; - dm_bufio_cond_resched(); + might_resched(); } dm_bufio_unlock(c); - dm_bufio_cond_resched(); + might_resched(); } mutex_unlock(&dm_bufio_clients_lock); }