From patchwork Tue Aug 15 15:11:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9902063 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C49D2603FB for ; Tue, 15 Aug 2017 15:14:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0B3928882 for ; Tue, 15 Aug 2017 15:14:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 953562888C; Tue, 15 Aug 2017 15:14:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A9A928884 for ; Tue, 15 Aug 2017 15:14:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752794AbdHOPOE (ORCPT ); Tue, 15 Aug 2017 11:14:04 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:63213 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752384AbdHOPNf (ORCPT ); Tue, 15 Aug 2017 11:13:35 -0400 Received: from wuerfel.lan ([95.208.155.18]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0Lr4bL-1d3MlB1j3j-00eeea; Tue, 15 Aug 2017 17:12:46 +0200 From: Arnd Bergmann To: Ulf Hansson Cc: Ingo Molnar , Byungchul Park , Peter Zijlstra , Arnd Bergmann , Linus Walleij , Shawn Lin , Adrian Hunter , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] mmc: test: reduce stack usage in mmc_test_nonblock_transfer Date: Tue, 15 Aug 2017 17:11:58 +0200 Message-Id: <20170815151242.2637861-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:EX8gypAObveb9AxycLxM9Jqra40wTFALiGOq+gDxHGWZiJzA0XL 4JP5j4rh8KU7y+OnugjdUWR1YHOOXBOrYoj7tsUJb0VfVRTFWF1c4zyRQyPM/zS08AOGCoc rCoZ9lMDcVoNQ3nh+BhbxpY0/2JEZqgYMHFC4HGiZvnslstYp9soCW1wzA/1di6apH/B5YZ ykppJOVA61WV9CDRSWRbQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:zwaNWyCGxBM=:gnG+IJi0DVDVN07TduvmFL OmLF2kCsPT0THyanaCY8FlwntyE0Ji31k/A0za72wgMx9ZkY9t23VvT+jtfYtYQDBzPhKlI6W VStAnjBZfukAZpEgXq3i4CAptdmyTjEeTjFYmGcTAeKnWjWdENBYMQKeu+w0/+6Nkv0Wv+/4h taZ24v6hhPnatJX5ECjb70eABkv1YKzsOr5o/OzWg4tcH+s2MVRcob4gXVNgvUXJ1ckr8U5ls Hw0VbQMKXfhw9wH2jupH7TiL+xrImD8mCwllyWPDm6utxd2V/iBo4uEp8uJwx7WkYj2rmzoKQ zSLjfoMDe0h57uelExMN0ASQ9pwUS1D7TOcjej/2KBNtk4lDQMVzf80PzUP7Eg2HXpTtirg+n SAyqndz7cjZkGCxUH+FuUEXzKzLt6C78yVufCzMDdCP2axJnykuXRcR07300O/pE90xOEk7Z4 T7ea25afidx2IV968vI+Oa/m8TTmT/PhZw3thto9dcwXX7fSpj6mCaaMSnhMMmFmPBxmZDpSc C4YKr3uiDDi/sjBGBww57YR4Ef1PT13EJuxaSMFg5knG0FRFbE59UwusZPJSqYlpDgqaQJG35 PZca1i9uzizxdDTQZSsTlbPXge3fr5ScjH8T1+Dh9ATdWGkplSZEfTtG+V/6IKVaqvhl0R2r5 3eS0F2t9fGLVufLCICv0AsZVA4R/aFsjL1bF+FZEptijecnE8EUQWn3k6X6FNBtpImt50EQFT /jVxsTNe4JzSU7Jjarpcel/JflX/TfUL3MiUvA== Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The new lockdep annotations for completions cause a warning in the mmc test module, in a function that now has four 150 byte structures on the stack: drivers/mmc/core/mmc_test.c: In function 'mmc_test_nonblock_transfer.constprop': drivers/mmc/core/mmc_test.c:892:1: error: the frame size of 1360 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] The mmc_test_ongoing_transfer function evidently had a similar problem, and worked around it by using dynamic allocation. This generalizes the approach used by mmc_test_ongoing_transfer() and applies it to mmc_test_nonblock_transfer() as well. Fixes: cd8084f91c02 ("locking/lockdep: Apply crossrelease to completions") Signed-off-by: Arnd Bergmann Acked-by: Adrian Hunter Tested-by: Adrian Hunter --- The patch causing this is currently part of linux-next, scheduled for 4.14, so it would be good to have this in the same release. Since the change is not entirely trivial, please test this before applying. --- drivers/mmc/core/mmc_test.c | 97 +++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 56 deletions(-) diff --git a/drivers/mmc/core/mmc_test.c b/drivers/mmc/core/mmc_test.c index 7a304a6e5bf1..478869805b96 100644 --- a/drivers/mmc/core/mmc_test.c +++ b/drivers/mmc/core/mmc_test.c @@ -800,38 +800,44 @@ static int mmc_test_check_broken_result(struct mmc_test_card *test, return ret; } +struct mmc_test_req { + struct mmc_request mrq; + struct mmc_command sbc; + struct mmc_command cmd; + struct mmc_command stop; + struct mmc_command status; + struct mmc_data data; +}; + /* * Tests nonblock transfer with certain parameters */ -static void mmc_test_nonblock_reset(struct mmc_request *mrq, - struct mmc_command *cmd, - struct mmc_command *stop, - struct mmc_data *data) +static void mmc_test_req_reset(struct mmc_test_req *rq) +{ + memset(rq, 0, sizeof(struct mmc_test_req)); + + rq->mrq.cmd = &rq->cmd; + rq->mrq.data = &rq->data; + rq->mrq.stop = &rq->stop; +} + +static struct mmc_test_req *mmc_test_req_alloc(void) { - memset(mrq, 0, sizeof(struct mmc_request)); - memset(cmd, 0, sizeof(struct mmc_command)); - memset(data, 0, sizeof(struct mmc_data)); - memset(stop, 0, sizeof(struct mmc_command)); + struct mmc_test_req *rq = kmalloc(sizeof(*rq), GFP_KERNEL); - mrq->cmd = cmd; - mrq->data = data; - mrq->stop = stop; + if (rq) + mmc_test_req_reset(rq); + + return rq; } + + static int mmc_test_nonblock_transfer(struct mmc_test_card *test, struct scatterlist *sg, unsigned sg_len, unsigned dev_addr, unsigned blocks, unsigned blksz, int write, int count) { - struct mmc_request mrq1; - struct mmc_command cmd1; - struct mmc_command stop1; - struct mmc_data data1; - - struct mmc_request mrq2; - struct mmc_command cmd2; - struct mmc_command stop2; - struct mmc_data data2; - + struct mmc_test_req *rq1, *rq2; struct mmc_test_async_req test_areq[2]; struct mmc_async_req *done_areq; struct mmc_async_req *cur_areq = &test_areq[0].areq; @@ -843,12 +849,16 @@ static int mmc_test_nonblock_transfer(struct mmc_test_card *test, test_areq[0].test = test; test_areq[1].test = test; - mmc_test_nonblock_reset(&mrq1, &cmd1, &stop1, &data1); - mmc_test_nonblock_reset(&mrq2, &cmd2, &stop2, &data2); + rq1 = mmc_test_req_alloc(); + rq2 = mmc_test_req_alloc(); + if (!rq1 || !rq2) { + ret = RESULT_FAIL; + goto err; + } - cur_areq->mrq = &mrq1; + cur_areq->mrq = &rq1->mrq; cur_areq->err_check = mmc_test_check_result_async; - other_areq->mrq = &mrq2; + other_areq->mrq = &rq2->mrq; other_areq->err_check = mmc_test_check_result_async; for (i = 0; i < count; i++) { @@ -861,14 +871,10 @@ static int mmc_test_nonblock_transfer(struct mmc_test_card *test, goto err; } - if (done_areq) { - if (done_areq->mrq == &mrq2) - mmc_test_nonblock_reset(&mrq2, &cmd2, - &stop2, &data2); - else - mmc_test_nonblock_reset(&mrq1, &cmd1, - &stop1, &data1); - } + if (done_areq) + mmc_test_req_reset(container_of(done_areq->mrq, + struct mmc_test_req, mrq)); + swap(cur_areq, other_areq); dev_addr += blocks; } @@ -877,8 +883,9 @@ static int mmc_test_nonblock_transfer(struct mmc_test_card *test, if (status != MMC_BLK_SUCCESS) ret = RESULT_FAIL; - return ret; err: + kfree(rq1); + kfree(rq2); return ret; } @@ -2329,28 +2336,6 @@ static int mmc_test_reset(struct mmc_test_card *test) return RESULT_FAIL; } -struct mmc_test_req { - struct mmc_request mrq; - struct mmc_command sbc; - struct mmc_command cmd; - struct mmc_command stop; - struct mmc_command status; - struct mmc_data data; -}; - -static struct mmc_test_req *mmc_test_req_alloc(void) -{ - struct mmc_test_req *rq = kzalloc(sizeof(*rq), GFP_KERNEL); - - if (rq) { - rq->mrq.cmd = &rq->cmd; - rq->mrq.data = &rq->data; - rq->mrq.stop = &rq->stop; - } - - return rq; -} - static int mmc_test_send_status(struct mmc_test_card *test, struct mmc_command *cmd) {