From patchwork Wed Sep 1 06:26:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 177672 Return-path: X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on void.printf.net X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.9 tests=RCVD_IN_DNSWL_LOW autolearn=disabled version=3.2.5 Envelope-to: chris@printf.net Delivery-date: Wed, 01 Sep 2010 07:27:15 +0100 Received: from lists.laptop.org ([18.85.2.145] helo=mail.laptop.org) by void.printf.net with esmtp (Exim 4.69) (envelope-from ) id 1Oqgmx-0006M9-GK for chris@printf.net; Wed, 01 Sep 2010 07:27:15 +0100 Received: by mail.laptop.org (Postfix) id 697C824511; Wed, 1 Sep 2010 02:26:56 -0400 (EDT) Delivered-To: cjb@laptop.org Received: from spam.laptop.org (spam.laptop.org [18.85.46.23]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.laptop.org (Postfix) with ESMTPS id 5438E24510 for ; Wed, 1 Sep 2010 02:26:56 -0400 (EDT) X-ASG-Debug-ID: 1283322431-0b7497250002-zHW3sV Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by spam.laptop.org with ESMTP id oaI4ZH0HWH4U7G99 for ; Wed, 01 Sep 2010 02:27:12 -0400 (EDT) X-Barracuda-Envelope-From: linux-mmc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753047Ab0IAG0a (ORCPT ); Wed, 1 Sep 2010 02:26:30 -0400 Received: from mail-ey0-f174.google.com ([209.85.215.174]:39920 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752862Ab0IAG01 (ORCPT ); Wed, 1 Sep 2010 02:26:27 -0400 Received: by mail-ey0-f174.google.com with SMTP id 6so348892eyb.19 for ; Tue, 31 Aug 2010 23:26:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references:in-reply-to:references; bh=u2Nzdo7HMZBak0Qi3eDf2t0HZxf9Zvx1XxhuZ3AO9fM=; b=r7Wb20PoW40GOqjYenJVgYOqoIhO5IBfukxLNZim5UgSPTFKKeP8dZtw0gD7siOu1J c82KBvt6IXHC62RCsl65MW/yvM58igLWYkst/n1WVlJ58/qVPejasfG0ajpAzuj5RCp7 RUcuYverIssuxw8cKH7rgsDJ57Pz/QHrwT/JQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=V1GcE8dohf0bsMhdRnb5egxmvbVwKTY+x1d/j8WqWU8AJGcQmwXrhjPdpCA60zn25A wC+cN3/RUdkBt/c+F8pgpoo5g2sCr7N6fV3pMCjzXyWEw/2yCxJ8G2X37m1vzBgnOYFM SBUPhZ22Ew1qkr5Bk8entJ0TNLH5HFvNaYfdw= Received: by 10.213.6.212 with SMTP id a20mr3431325eba.24.1283322386733; Tue, 31 Aug 2010 23:26:26 -0700 (PDT) Received: from localhost.localdomain (starua.cc.colocall.com [62.149.23.157]) by mx.google.com with ESMTPS id v8sm15477371eeh.14.2010.08.31.23.26.24 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 31 Aug 2010 23:26:26 -0700 (PDT) From: Andy Shevchenko To: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andrew Morton , Adrian Hunter , Andy Shevchenko X-ASG-Orig-Subj: [PATCH 3/3] mmc_test: collect data and show it via sysfs by demand Subject: [PATCH 3/3] mmc_test: collect data and show it via sysfs by demand Date: Wed, 1 Sep 2010 09:26:47 +0300 Message-Id: <5f816a17d1a3a630eeb2850ec217d32a9b55fc8d.1283276161.git.ext-andriy.shevchenko@nokia.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: References: <756943b35144532a3c8de22c6dcfb179e5a7f69f.1283276161.git.ext-andriy.shevchenko@nokia.com> In-Reply-To: References: Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Barracuda-Connect: vger.kernel.org[209.132.180.67] X-Barracuda-Start-Time: 1283322432 X-Barracuda-URL: http://18.85.46.23:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at laptop.org X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.5 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.39584 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c index 5423ac9..3cfef37 100644 --- a/drivers/mmc/card/mmc_test.c +++ b/drivers/mmc/card/mmc_test.c @@ -16,6 +16,7 @@ #include #include +#include #define RESULT_OK 0 #define RESULT_FAIL 1 @@ -66,6 +67,28 @@ struct mmc_test_area { }; /** + * struct mmc_test_transfer_result - container of the transfer results for + * performance tests. + */ +struct mmc_test_transfer_result { + struct list_head link; + unsigned int count; + unsigned int sectors; + struct timespec ts; + unsigned int rate; +}; + +/** + * struct mmc_test_general_result - container of the results for tests. + */ +struct mmc_test_general_result { + struct list_head link; + int testcase; + int result; + struct list_head transfer; +}; + +/** * struct mmc_test_card - test information. * @card: card under test * @scratch: transfer buffer @@ -81,7 +104,8 @@ struct mmc_test_card { #ifdef CONFIG_HIGHMEM struct page *highmem; #endif - struct mmc_test_area area; + struct mmc_test_area area; + struct list_head *result; }; /*******************************************************************/ @@ -420,6 +444,10 @@ static void mmc_test_print_rate(struct mmc_test_card *test, uint64_t bytes, { unsigned int rate, sectors = bytes >> 9; struct timespec ts; + struct mmc_test_transfer_result *transfer; + struct mmc_test_general_result *result = + list_entry(test->result->prev, struct mmc_test_general_result, + link); ts = timespec_sub(*ts2, *ts1); @@ -430,6 +458,15 @@ static void mmc_test_print_rate(struct mmc_test_card *test, uint64_t bytes, mmc_hostname(test->card->host), sectors, sectors >> 1, (sectors == 1 ? ".5" : ""), (unsigned long)ts.tv_sec, (unsigned long)ts.tv_nsec, rate / 1000, rate / 1024); + + transfer = kmalloc(sizeof(struct mmc_test_transfer_result), GFP_KERNEL); + + transfer->count = 0; + transfer->sectors = sectors; + memcpy(&transfer->ts, &ts, sizeof(struct timespec)); + transfer->rate = rate; + + list_add_tail(&transfer->link, &result->transfer); } /* @@ -442,6 +479,10 @@ static void mmc_test_print_avg_rate(struct mmc_test_card *test, uint64_t bytes, unsigned int rate, sectors = bytes >> 9; uint64_t tot = bytes * count; struct timespec ts; + struct mmc_test_transfer_result *transfer; + struct mmc_test_general_result *result = + list_entry(test->result->prev, struct mmc_test_general_result, + link); ts = timespec_sub(*ts2, *ts1); @@ -453,6 +494,15 @@ static void mmc_test_print_avg_rate(struct mmc_test_card *test, uint64_t bytes, sectors >> 1, (sectors == 1 ? ".5" : ""), (unsigned long)ts.tv_sec, (unsigned long)ts.tv_nsec, rate / 1000, rate / 1024); + + transfer = kmalloc(sizeof(struct mmc_test_transfer_result), GFP_KERNEL); + + transfer->count = count; + transfer->sectors = sectors; + memcpy(&transfer->ts, &ts, sizeof(struct timespec)); + transfer->rate = rate; + + list_add_tail(&transfer->link, &result->transfer); } /* @@ -1847,6 +1897,8 @@ static void mmc_test_run(struct mmc_test_card *test, long testcase) mmc_claim_host(test->card->host); for (i = 0;i < ARRAY_SIZE(mmc_test_cases);i++) { + struct mmc_test_general_result *result; + if (testcase && ((i + 1) != testcase)) continue; @@ -1865,6 +1917,11 @@ static void mmc_test_run(struct mmc_test_card *test, long testcase) } } + result = kzalloc(sizeof(struct mmc_test_general_result), + GFP_KERNEL); + INIT_LIST_HEAD(&result->transfer); + list_add_tail(&result->link, test->result); + ret = mmc_test_cases[i].run(test); switch (ret) { case RESULT_OK: @@ -1890,6 +1947,10 @@ static void mmc_test_run(struct mmc_test_card *test, long testcase) mmc_hostname(test->card->host), ret); } + /* Save the result */ + result->testcase = i; + result->result = ret; + if (mmc_test_cases[i].cleanup) { ret = mmc_test_cases[i].cleanup(test); if (ret) { @@ -1907,13 +1968,57 @@ static void mmc_test_run(struct mmc_test_card *test, long testcase) mmc_hostname(test->card->host)); } +static struct list_head mmc_test_result; + +static void mmc_test_result_free(struct list_head *result) +{ + struct mmc_test_general_result *gr, *grs; + + list_for_each_entry_safe(gr, grs, result, link) { + struct mmc_test_transfer_result *tr, *trs; + + list_for_each_entry_safe(tr, trs, &gr->transfer, link) + kfree(tr); + kfree(gr); + } +} + static ssize_t mmc_test_show(struct device *dev, struct device_attribute *attr, char *buf) { + struct mmc_test_general_result *result; + char *p = buf; + size_t len = PAGE_SIZE; + mutex_lock(&mmc_test_lock); + + list_for_each_entry(result, &mmc_test_result, link) { + struct mmc_test_transfer_result *transfer; + int ret; + + ret = snprintf(p, len, "Test %d: %d\n", result->testcase + 1, + result->result); + if (ret < 0) + return ret; + p += ret; + len -= ret; + + list_for_each_entry(transfer, &result->transfer, link) { + ret = snprintf(p, len, "%u %d %lu.%09lu %u\n", + transfer->count, transfer->sectors, + (unsigned long)transfer->ts.tv_sec, + (unsigned long)transfer->ts.tv_nsec, + transfer->rate); + if (ret < 0) + return ret; + p += ret; + len -= ret; + } + } + mutex_unlock(&mmc_test_lock); - return 0; + return PAGE_SIZE - len; } static ssize_t mmc_test_store(struct device *dev, @@ -1932,6 +2037,10 @@ static ssize_t mmc_test_store(struct device *dev, test->card = card; + mmc_test_result_free(&mmc_test_result); + INIT_LIST_HEAD(&mmc_test_result); + test->result = &mmc_test_result; + test->buffer = kzalloc(BUFFER_SIZE, GFP_KERNEL); #ifdef CONFIG_HIGHMEM test->highmem = alloc_pages(GFP_KERNEL | __GFP_HIGHMEM, BUFFER_ORDER); @@ -1969,6 +2078,8 @@ static int mmc_test_probe(struct mmc_card *card) if (ret) return ret; + INIT_LIST_HEAD(&mmc_test_result); + dev_info(&card->dev, "Card claimed for testing.\n"); return 0; @@ -1976,6 +2087,7 @@ static int mmc_test_probe(struct mmc_card *card) static void mmc_test_remove(struct mmc_card *card) { + mmc_test_result_free(&mmc_test_result); device_remove_file(&card->dev, &dev_attr_test); }