From patchwork Wed Jan 2 08:59:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 10746143 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DD7351399 for ; Wed, 2 Jan 2019 08:59:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD8EE2847E for ; Wed, 2 Jan 2019 08:59:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C037D28496; Wed, 2 Jan 2019 08:59:45 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65E012847E for ; Wed, 2 Jan 2019 08:59:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 970838E0011; Wed, 2 Jan 2019 03:59:43 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8AC208E0002; Wed, 2 Jan 2019 03:59:43 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 723E98E0011; Wed, 2 Jan 2019 03:59:43 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by kanga.kvack.org (Postfix) with ESMTP id EF6358E0002 for ; Wed, 2 Jan 2019 03:59:42 -0500 (EST) Received: by mail-lj1-f197.google.com with SMTP id t22-v6so8802174lji.14 for ; Wed, 02 Jan 2019 00:59:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=eD6vdBsepWppEQ05SRQmT4a1zoaGvTyTVp6rRdsMwk0=; b=Py7WZHnjEbQamSmrdKkxSBwlhBlv0xu1OW0MYfBMdiwzLZ5++fLV4Jq5fy2fxWaXOa sZAh7o354HHj8LcCg+mJPqa8IC+khlqdHGdwLiS+mRD5MI5zPH/6NxlsKnyOAcJKUkHJ 8mgC8Lo1l1jzMUX3gTgOpB/RUcQJf64ZnOjeGLOUllJLOQqkgN0L6uptqJ09pJR/8rf3 UZX/NEVHcG94AvQO64B/NL1U9iYxsE9At4PjTrpm7fXef+H0A8nP/ibC8qEqtkcEwCui NFfAXjMCUaQUR2+0xVIrmJY5c9946zg48gAZfSkLXmzH2u6693jSBy5LggXYZ8pka+a9 BImg== X-Gm-Message-State: AA+aEWZ+I707S9x3tEdREuQXn6/SIKls0yhETdIHG846h+iFn+954XzZ YCp0ArgwSoyzKiiJ789WcyE2Uz7JH314YIvK1NhNnFv9Grvt+DDIAnGwSFobPVLZxtfQojkUrxi jTk7UShU3FO1oJ0vnih90wo3IuYllxwaHI/Dvsjv10bOavGwd8nMXVksXnX+4qAF5gBBR9oeE1s 2rtAMm2ol76qPEctE2IwTy67pWDiM7HovrE7vGReM1vRgUQPm/a2EXf8ocZ2SakOklFWJIntmcb ZS5LCZqVjYYXbbgGkyqMHQybrTf+DJwZPeIl7Q4vqZ+w3jqyoVHDamJSbp6RZqdyAG83Bpk3DYW TnS+oujmRbFXFWre5bulDAHYxLK3pg4G1pkXaXrUPl1nxWQj/chmAyPfs2NTTSlpsjs+vNbohNI K X-Received: by 2002:a19:10a4:: with SMTP id 36mr20677363lfq.60.1546419582344; Wed, 02 Jan 2019 00:59:42 -0800 (PST) X-Received: by 2002:a19:10a4:: with SMTP id 36mr20677332lfq.60.1546419581013; Wed, 02 Jan 2019 00:59:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546419580; cv=none; d=google.com; s=arc-20160816; b=qtLE4xRJEe6RjzsY1jNczioc1EZzsjqP0YTonLfQ7mxdkoU68ibLxpeWain0ao/AQW V1rqesLM4zzzG6KLyj8NksGC8m4+2bOgjrVoKJxoI4lAHu//o0e8O5msmdqrnrWEXG1s kMXK9QAf+oomfMlt/h9ZRNwiRK76T3L4nq/e/Fy4ueCxiCI84AFm8726CxpNmbmvLvb9 QRTyfcZ938vnGzDo4hnR8QYDZOWedG18bSAPmNPXcbh668UQmFenIDr0K2woF6CNbqV4 j691QlVFb3Pq9uu8VrDKYynoa7Zx/EXmOE8hUZi2oxOwUdsU11lzO9GHjOzsB5kvx7n1 bptg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eD6vdBsepWppEQ05SRQmT4a1zoaGvTyTVp6rRdsMwk0=; b=iFeo1+uvxU0qNAZxAD7OnXQR5d0LRAAah5bHklFesvDNTpKxiYgnjbcwX3H60nH6AA n7Mdy0pwvBPEYlScHmk+36VHf2EKfDdUDUsveMpQUNu70b1ZbuYcTIqSzBoeN5a0/vpo VehEs2PVw3xmC9UeNkkNxkOm7t4sBIud5qL+sWRYSjwFUbp/aH7RXkmJTjRQlpYRCfI+ 5/FKgSM8Z0kG8qKVsYBPhvMuSAl4rOh2TI2LCYkeOa2iRuq2Azsa6awTh+PnfLyuZ94a TnKtceYnjqx4mJJnAgtVNW7Hhqve8gljyrG0GK0uiEly4CECPaXDGXDbt/ir4/8JK/oQ Ewjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LdX+L9oJ; spf=pass (google.com: domain of urezki@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id w6-v6sor29536042lji.26.2019.01.02.00.59.40 for (Google Transport Security); Wed, 02 Jan 2019 00:59:40 -0800 (PST) Received-SPF: pass (google.com: domain of urezki@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LdX+L9oJ; spf=pass (google.com: domain of urezki@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eD6vdBsepWppEQ05SRQmT4a1zoaGvTyTVp6rRdsMwk0=; b=LdX+L9oJjaEbV8ti2QJpvLcZOUtKiQVck+e5aVjKDtYH2v0lAytvrjIX0tGf2Kcnqi KTRLGvbOaerIEhGNAONWpz42zy765uVTfz8fO16111mBmaoclKa8rjmUkGxNLvhRlR23 IG8mE7gbO7BbtNvkd15RuWvkAyx3p7p7z6+1Dv08LFkM4aSnH5dceEc6yl9dBbUck2jT L+gj2v7BNSwoHqy98s0rvWcYViVMznos7a78sPVgvMaYBqYycfvBcPGfgCCWdNesgZhk 6bsjI6wKFJOuVR6ZlVrhWEUwaR0Kew77fFAEwshjwg5vohuWP3bIEEwp9zu703n1sl2U 6wMA== X-Google-Smtp-Source: ALg8bN7hJI84B2jJc/Xzb8Y9ANMnx2S/0tA8wHEFVPx9/IPXJrgzwTuz57uq8dCl5bMOQNIzuO3MVw== X-Received: by 2002:a2e:3803:: with SMTP id f3-v6mr24073174lja.169.1546419580634; Wed, 02 Jan 2019 00:59:40 -0800 (PST) Received: from localhost.localdomain (mm-79-4-214-37.mogilev.dynamic.pppoe.byfly.by. [37.214.4.79]) by smtp.gmail.com with ESMTPSA id 10sm7489670ljr.4.2019.01.02.00.59.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Jan 2019 00:59:40 -0800 (PST) From: "Uladzislau Rezki (Sony)" To: Michal Hocko , Kees Cook , Shuah Khan , Andrew Morton , linux-mm@kvack.org Cc: LKML , Matthew Wilcox , Oleksiy Avramchenko , Thomas Gleixner , "Uladzislau Rezki (Sony)" Subject: [RFC v3 1/3] vmalloc: export __vmalloc_node_range for CONFIG_TEST_VMALLOC_MODULE Date: Wed, 2 Jan 2019 09:59:22 +0100 Message-Id: <20190102085924.14145-2-urezki@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190102085924.14145-1-urezki@gmail.com> References: <20190102085924.14145-1-urezki@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Export __vmaloc_node_range() function if CONFIG_TEST_VMALLOC_MODULE is enabled. Some test cases in vmalloc test suite module require and make use of that function. Please note, that it is not supposed to be used for other purposes. We need it only for performance analysis, stressing and stability check of vmalloc allocator. Signed-off-by: Uladzislau Rezki (Sony) --- mm/vmalloc.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index cfea25be7754..1f24aecd1d7e 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1764,6 +1764,15 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align, return NULL; } +/* + * This is only for performance analysis of vmalloc and stress purpose. + * It is required by vmalloc test module, therefore do not use it other + * than that. + */ +#ifdef CONFIG_TEST_VMALLOC_MODULE +EXPORT_SYMBOL_GPL(__vmalloc_node_range); +#endif + /** * __vmalloc_node - allocate virtually contiguous memory * @size: allocation size From patchwork Wed Jan 2 08:59:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 10746145 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6A40F746 for ; Wed, 2 Jan 2019 08:59:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59C492847E for ; Wed, 2 Jan 2019 08:59:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D6C328496; Wed, 2 Jan 2019 08:59:49 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 207002847E for ; Wed, 2 Jan 2019 08:59:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 887568E0012; Wed, 2 Jan 2019 03:59:46 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 80DC68E0002; Wed, 2 Jan 2019 03:59:46 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 664388E0012; Wed, 2 Jan 2019 03:59:46 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by kanga.kvack.org (Postfix) with ESMTP id CA6D78E0002 for ; Wed, 2 Jan 2019 03:59:45 -0500 (EST) Received: by mail-lf1-f69.google.com with SMTP id c5so2886429lfi.7 for ; Wed, 02 Jan 2019 00:59:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=3coeA0tvuUbIXj6QpLggBe9qe3JEzvmhpFjBK2XFWYU=; b=LdRSE/a4ID7NOlHhZ2a5mSOYvhQCCUfQ30BSTx5gtW9zuy2jyB2S21WGMQvYUPx7A7 quIsrNKDR3VUQVDmdC+V7EvFU3KFh4sjgZF3tDV5YZfAMZi+4FU3zm362tRxWCdAMFXo t6WkcXzBHIPzX1p0G5jL8rPGAiK1hO6jeEsIHDB5oqdfMa36uYQbOFF314kgALcWODfp USAc1vr3RtYtJpmgSr86U0iERGxCeG1q8Cb7qDhPBvM0A1TA+n2nfNIUcLJiPgvuUtdH +hc88iPu6cwboMnOytJUDV5cTxgYmtf6k7FSoVf3dy/nWRqZH/H3OOTcJiovSWlY66nn H6Hg== X-Gm-Message-State: AA+aEWZjdzy6HqnZSTsEm9FwNlhQVo3zREHd3zCD4HAbxbLRBBmRuSr5 4CYgYFf5qfiQmuBRG+WciV4m2YUU3KmziS8i9+elPGo67OhZCXvSsaWyeVQGofZfGgCuAYMZojl EETDkhETbBE0tthMQr154/aQNJ/9Ral10kXD01pq2EAzTanZ93IcP2dzqZ/J8w53NzkbxQENtA5 Ug6bON26oaz24KT46I6ujatXZUqL7tLIqicjGCzyAdIETajrIjXAFgjjyTtjN0kTcsgF1ZtYbKf HeI7HsK+6n88e7iRgjZAeWTDrqKJlBza5foDJ9qHtE5pBiCUH615PKejuZffsZkNINSSq7UeC3e 6O5qbzCgxxL217PkHVKtIt5HxRBywEAVK2xp+vqVdW1fbWOZpK2V8uqU53HjIF6QXxcz4RCG9m+ Z X-Received: by 2002:a2e:630a:: with SMTP id x10-v6mr23147737ljb.11.1546419585073; Wed, 02 Jan 2019 00:59:45 -0800 (PST) X-Received: by 2002:a2e:630a:: with SMTP id x10-v6mr23147707ljb.11.1546419583349; Wed, 02 Jan 2019 00:59:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546419583; cv=none; d=google.com; s=arc-20160816; b=xFowtWkT0xxmal1mlUkKSk+xtZJGDwHpMe9GrEVTDyMhQk8i3AE7haLPFiIt9VxS0X 6SikUxrplg4vOcgaDWFAZokmv/KeEUo5b3n4/OmwUgb7mPIaTGIzhzCrO75CqqPIbZmY wL8h76JYALZVB/wwJ+PPhDwLokyTYuknS1wXIwAdw0lA+xcDz1bIBxn8TSrLg3j5Uwxg 9W4BPghqJHhyG8Y9Jrx5deE7zXxw+2ku/JenmzvEBA3HtFAqv4B5v611A8Z7Do1tcAE8 OSX7KniVx47wr7fwDNra4+pBp/HuefyYCzTOuMY/IS7k/1uUs1ZXPeQpU3EESEKacNqU 5iew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3coeA0tvuUbIXj6QpLggBe9qe3JEzvmhpFjBK2XFWYU=; b=t6cjTd2dZSobfGa2FUCRgqdcdh4SuhEkPZ1HC5wY6RBDU2oMYlXlyUpI4f4+QQkZHl EVffdXXCkHu8a8OOndEYfRO4sijlxnJ+UCMd1rrDaUR6rAg10N1AvCRp6LgAcKaQpJj+ Jb0L8OfFnlq9UzHQCkhtJpMhGKLFzVCHrYEBHpJjcR9Vg5gXi51TFxtzRXrmPSHWcu7/ Qa25hOdROcPuwAvJOMWDHj1LtO4LFxZoliiQNm5XmbDu7kosXa3PTIuMhi/69f+tQo+a lkQ4UkrZpZQMc/R7l57QECZpZtstcsFt0/cosdVQat40ObKDnzBD5zWonA3bUigTHLs2 hkJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fkYr5ZiO; spf=pass (google.com: domain of urezki@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id m23sor12991846lfl.47.2019.01.02.00.59.43 for (Google Transport Security); Wed, 02 Jan 2019 00:59:43 -0800 (PST) Received-SPF: pass (google.com: domain of urezki@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fkYr5ZiO; spf=pass (google.com: domain of urezki@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3coeA0tvuUbIXj6QpLggBe9qe3JEzvmhpFjBK2XFWYU=; b=fkYr5ZiORDddS7hDBcZH8pWoIqTEWNy3TOyROZHMZye/TuWyhb0zKqhx7k2BfXHmWJ vAu8fKf99nfW05yJ3SqU6hSlSmPw3y3nCRQKfP5bBgRZ+iH007mBqiDOAVhC45YUDGIg OLJH0VP6JoXaDEysj5PIeRNLqafTGRkEJwLq88SM4dVUZduI5e3b/COKoReKFMSDobRj /LHc8swGrivJiYIwcSmtba5DyHj7+YoNz+71yv151fc4i6BAhYYh8xXi5vOc7q902shn iO/4GCB5On1DJhhpU/S9VgfQ3+g3LdjpxLbSM/uoGRMp0e1/kRUApcobm6jQtIygy0oX 2Y4Q== X-Google-Smtp-Source: AFSGD/USXO+W2uqozN69DwY+ZG9tjsMQrxotT0KgCb3iUMS7wK99OjeyzHycUf5beoerU+q/ZZRMfQ== X-Received: by 2002:a19:2584:: with SMTP id l126mr20231560lfl.69.1546419582598; Wed, 02 Jan 2019 00:59:42 -0800 (PST) Received: from localhost.localdomain (mm-79-4-214-37.mogilev.dynamic.pppoe.byfly.by. [37.214.4.79]) by smtp.gmail.com with ESMTPSA id 10sm7489670ljr.4.2019.01.02.00.59.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Jan 2019 00:59:41 -0800 (PST) From: "Uladzislau Rezki (Sony)" To: Michal Hocko , Kees Cook , Shuah Khan , Andrew Morton , linux-mm@kvack.org Cc: LKML , Matthew Wilcox , Oleksiy Avramchenko , Thomas Gleixner , "Uladzislau Rezki (Sony)" Subject: [RFC v3 2/3] vmalloc: add test driver to analyse vmalloc allocator Date: Wed, 2 Jan 2019 09:59:23 +0100 Message-Id: <20190102085924.14145-3-urezki@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190102085924.14145-1-urezki@gmail.com> References: <20190102085924.14145-1-urezki@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This adds a new kernel module for analysis of vmalloc allocator. It is only enabled as a module. There are two main reasons this module should be used for: performance evaluation and stressing of vmalloc subsystem. It consists of several test cases. As of now there are 8. The module has five parameters we can specify to change its the behaviour. 1) run_test_mask - set of tests to be run id: 1, name: fix_size_alloc_test id: 2, name: full_fit_alloc_test id: 4, name: long_busy_list_alloc_test id: 8, name: random_size_alloc_test id: 16, name: fix_align_alloc_test id: 32, name: random_size_align_alloc_test id: 64, name: align_shift_alloc_test id: 128, name: pcpu_alloc_test By default all tests are in run test mask. If you want to select some specific tests it is possible to pass the mask. For example for first, second and fourth tests we go 11 value. 2) test_repeat_count - how many times each test should be repeated By default it is one time per test. It is possible to pass any number. As high the value is the test duration gets increased. 3) test_loop_count - internal test loop counter. By default it is set to 1000000. 4) single_cpu_test - use one CPU to run the tests By default this parameter is set to false. It means that all online CPUs execute tests. By setting it to 1, the tests are executed by first online CPU only. 5) sequential_test_order - run tests in sequential order By default this parameter is set to false. It means that before running tests the order is shuffled. It is possible to make it sequential, just set it to 1. Performance analysis: In order to evaluate performance of vmalloc allocations, usually it makes sense to use only one CPU that runs tests, use sequential order, number of repeat tests can be different as well as set of test mask. For example if we want to run all tests, to use one CPU and repeat each test 3 times. Insert the module passing following parameters: single_cpu_test=1 sequential_test_order=1 test_repeat_count=3 with following output: Summary: fix_size_alloc_test passed: 3 failed: 0 repeat: 3 loops: 1000000 avg: 901177 usec Summary: full_fit_alloc_test passed: 3 failed: 0 repeat: 3 loops: 1000000 avg: 1039341 usec Summary: long_busy_list_alloc_test passed: 3 failed: 0 repeat: 3 loops: 1000000 avg: 11775763 usec Summary: random_size_alloc_test passed 3: failed: 0 repeat: 3 loops: 1000000 avg: 6081992 usec Summary: fix_align_alloc_test passed: 3 failed: 0 repeat: 3, loops: 1000000 avg: 2003712 usec Summary: random_size_align_alloc_test passed: 3 failed: 0 repeat: 3 loops: 1000000 avg: 2895689 usec Summary: align_shift_alloc_test passed: 0 failed: 3 repeat: 3 loops: 1000000 avg: 573 usec Summary: pcpu_alloc_test passed: 3 failed: 0 repeat: 3 loops: 1000000 avg: 95802 usec All test took CPU0=192945605995 cycles The align_shift_alloc_test is expected to be failed. Stressing: In order to stress the vmalloc subsystem we run all available test cases on all available CPUs simultaneously. In order to prevent constant behaviour pattern, the test cases array is shuffled by default to randomize the order of test execution. For example if we want to run all tests(default), use all online CPUs(default) with shuffled order(default) and to repeat each test 30 times. The command would be like: modprobe vmalloc_test test_repeat_count=30 Expected results are the system is alive, there are no any BUG_ONs or Kernel Panics the tests are completed, no memory leaks. Signed-off-by: Uladzislau Rezki (Sony) --- lib/Kconfig.debug | 12 ++ lib/Makefile | 1 + lib/test_vmalloc.c | 543 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 556 insertions(+) create mode 100644 lib/test_vmalloc.c diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 8838d1158d19..0c027b2fef0a 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -1851,6 +1851,18 @@ config TEST_LKM If unsure, say N. +config TEST_VMALLOC + tristate "Test module for stress/performance analysis of vmalloc allocator" + default n + depends on m + help + This builds the "test_vmalloc" module that should be used for + stress and performance analysis. So, any new change for vmalloc + subsystem can be evaluated from performance and stability point + of view. + + If unsure, say N. + config TEST_USER_COPY tristate "Test user/kernel boundary protections" default n diff --git a/lib/Makefile b/lib/Makefile index 90dc5520b784..2caa6161b417 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -57,6 +57,7 @@ UBSAN_SANITIZE_test_ubsan.o := y obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o obj-$(CONFIG_TEST_LIST_SORT) += test_list_sort.o obj-$(CONFIG_TEST_LKM) += test_module.o +obj-$(CONFIG_TEST_VMALLOC) += test_vmalloc.o obj-$(CONFIG_TEST_OVERFLOW) += test_overflow.o obj-$(CONFIG_TEST_RHASHTABLE) += test_rhashtable.o obj-$(CONFIG_TEST_SORT) += test_sort.o diff --git a/lib/test_vmalloc.c b/lib/test_vmalloc.c new file mode 100644 index 000000000000..f852b404f436 --- /dev/null +++ b/lib/test_vmalloc.c @@ -0,0 +1,543 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * Test module for stress and analyze performance of vmalloc allocator. + * (C) 2018 Uladzislau Rezki (Sony) + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __param(type, name, init, msg) \ + static type name = init; \ + module_param(name, type, 0444); \ + MODULE_PARM_DESC(name, msg) \ + +__param(bool, single_cpu_test, false, + "Use single first online CPU to run tests"); + +__param(bool, sequential_test_order, false, + "Use sequential stress tests order"); + +__param(int, test_repeat_count, 1, + "Set test repeat counter"); + +__param(int, test_loop_count, 1000000, + "Set test loop counter"); + +__param(int, run_test_mask, INT_MAX, + "Set tests specified in the mask.\n\n" + "\t\tid: 1, name: fix_size_alloc_test\n" + "\t\tid: 2, name: full_fit_alloc_test\n" + "\t\tid: 4, name: long_busy_list_alloc_test\n" + "\t\tid: 8, name: random_size_alloc_test\n" + "\t\tid: 16, name: fix_align_alloc_test\n" + "\t\tid: 32, name: random_size_align_alloc_test\n" + "\t\tid: 64, name: align_shift_alloc_test\n" + "\t\tid: 128, name: pcpu_alloc_test\n" + /* Add a new test case description here. */ +); + +/* + * Depends on single_cpu_test parameter. If it is true, then + * use first online CPU to trigger a test on, otherwise go with + * all online CPUs. + */ +static cpumask_t cpus_run_test_mask = CPU_MASK_NONE; + +/* + * Read write semaphore for synchronization of setup + * phase that is done in main thread and workers. + */ +static DECLARE_RWSEM(prepare_for_test_rwsem); + +/* + * Completion tracking for worker threads. + */ +static DECLARE_COMPLETION(test_all_done_comp); +static atomic_t test_n_undone = ATOMIC_INIT(0); + +static inline void +test_report_one_done(void) +{ + if (atomic_dec_and_test(&test_n_undone)) + complete(&test_all_done_comp); +} + +static int random_size_align_alloc_test(void) +{ + unsigned long size, align, rnd; + void *ptr; + int i; + + for (i = 0; i < test_loop_count; i++) { + get_random_bytes(&rnd, sizeof(rnd)); + + /* + * Maximum 1024 pages, if PAGE_SIZE is 4096. + */ + align = 1 << (rnd % 23); + + /* + * Maximum 10 pages. + */ + size = ((rnd % 10) + 1) * PAGE_SIZE; + + ptr = __vmalloc_node_range(size, align, + VMALLOC_START, VMALLOC_END, + GFP_KERNEL | __GFP_ZERO, + PAGE_KERNEL, + 0, 0, __builtin_return_address(0)); + + if (!ptr) + return -1; + + vfree(ptr); + } + + return 0; +} + +/* + * This test case is supposed to be failed. + */ +static int align_shift_alloc_test(void) +{ + unsigned long align; + void *ptr; + int i; + + for (i = 0; i < BITS_PER_LONG; i++) { + align = ((unsigned long) 1) << i; + + ptr = __vmalloc_node_range(PAGE_SIZE, align, + VMALLOC_START, VMALLOC_END, + GFP_KERNEL | __GFP_ZERO, + PAGE_KERNEL, + 0, 0, __builtin_return_address(0)); + + if (!ptr) + return -1; + + vfree(ptr); + } + + return 0; +} + +static int fix_align_alloc_test(void) +{ + void *ptr; + int i; + + for (i = 0; i < test_loop_count; i++) { + ptr = __vmalloc_node_range(5 * PAGE_SIZE, + THREAD_ALIGN << 1, + VMALLOC_START, VMALLOC_END, + GFP_KERNEL | __GFP_ZERO, + PAGE_KERNEL, + 0, 0, __builtin_return_address(0)); + + if (!ptr) + return -1; + + vfree(ptr); + } + + return 0; +} + +static int random_size_alloc_test(void) +{ + unsigned int n; + void *p; + int i; + + for (i = 0; i < test_loop_count; i++) { + get_random_bytes(&n, sizeof(i)); + n = (n % 100) + 1; + + p = vmalloc(n * PAGE_SIZE); + + if (!p) + return -1; + + *((__u8 *)p) = 1; + vfree(p); + } + + return 0; +} + +static int long_busy_list_alloc_test(void) +{ + void *ptr_1, *ptr_2; + void **ptr; + int rv = -1; + int i; + + ptr = vmalloc(sizeof(void *) * 15000); + if (!ptr) + return rv; + + for (i = 0; i < 15000; i++) + ptr[i] = vmalloc(1 * PAGE_SIZE); + + for (i = 0; i < test_loop_count; i++) { + ptr_1 = vmalloc(100 * PAGE_SIZE); + if (!ptr_1) + goto leave; + + ptr_2 = vmalloc(1 * PAGE_SIZE); + if (!ptr_2) { + vfree(ptr_1); + goto leave; + } + + *((__u8 *)ptr_1) = 0; + *((__u8 *)ptr_2) = 1; + + vfree(ptr_1); + vfree(ptr_2); + } + + /* Success */ + rv = 0; + +leave: + for (i = 0; i < 15000; i++) + vfree(ptr[i]); + + vfree(ptr); + return rv; +} + +static int full_fit_alloc_test(void) +{ + void **ptr, **junk_ptr, *tmp; + int junk_length; + int rv = -1; + int i; + + junk_length = fls(num_online_cpus()); + junk_length *= (32 * 1024 * 1024 / PAGE_SIZE); + + ptr = vmalloc(sizeof(void *) * junk_length); + if (!ptr) + return rv; + + junk_ptr = vmalloc(sizeof(void *) * junk_length); + if (!junk_ptr) { + vfree(ptr); + return rv; + } + + for (i = 0; i < junk_length; i++) { + ptr[i] = vmalloc(1 * PAGE_SIZE); + junk_ptr[i] = vmalloc(1 * PAGE_SIZE); + } + + for (i = 0; i < junk_length; i++) + vfree(junk_ptr[i]); + + for (i = 0; i < test_loop_count; i++) { + tmp = vmalloc(1 * PAGE_SIZE); + + if (!tmp) + goto error; + + *((__u8 *)tmp) = 1; + vfree(tmp); + } + + /* Success */ + rv = 0; + +error: + for (i = 0; i < junk_length; i++) + vfree(ptr[i]); + + vfree(ptr); + vfree(junk_ptr); + + return rv; +} + +static int fix_size_alloc_test(void) +{ + void *ptr; + int i; + + for (i = 0; i < test_loop_count; i++) { + ptr = vmalloc(3 * PAGE_SIZE); + + if (!ptr) + return -1; + + *((__u8 *)ptr) = 0; + + vfree(ptr); + } + + return 0; +} + +static int +pcpu_alloc_test(void) +{ + int rv = 0; +#ifndef CONFIG_NEED_PER_CPU_KM + void __percpu **pcpu; + size_t size, align; + int i; + + pcpu = vmalloc(sizeof(void __percpu *) * 35000); + if (!pcpu) + return -1; + + for (i = 0; i < 35000; i++) { + unsigned int r; + + get_random_bytes(&r, sizeof(i)); + size = (r % (PAGE_SIZE / 4)) + 1; + + /* + * Maximum PAGE_SIZE + */ + get_random_bytes(&r, sizeof(i)); + align = 1 << ((i % 11) + 1); + + pcpu[i] = __alloc_percpu(size, align); + if (!pcpu[i]) + rv = -1; + } + + for (i = 0; i < 35000; i++) + free_percpu(pcpu[i]); + + vfree(pcpu); +#endif + return rv; +} + +struct test_case_desc { + const char *test_name; + int (*test_func)(void); +}; + +static struct test_case_desc test_case_array[] = { + { "fix_size_alloc_test", fix_size_alloc_test }, + { "full_fit_alloc_test", full_fit_alloc_test }, + { "long_busy_list_alloc_test", long_busy_list_alloc_test }, + { "random_size_alloc_test", random_size_alloc_test }, + { "fix_align_alloc_test", fix_align_alloc_test }, + { "random_size_align_alloc_test", random_size_align_alloc_test }, + { "align_shift_alloc_test", align_shift_alloc_test }, + { "pcpu_alloc_test", pcpu_alloc_test }, + /* Add a new test case here. */ +}; + +struct test_case_data { + int test_failed; + int test_passed; + s64 time; +}; + +/* Split it to get rid of: WARNING: line over 80 characters */ +static struct test_case_data + per_cpu_test_data[NR_CPUS][ARRAY_SIZE(test_case_array)]; + +static struct test_driver { + struct task_struct *task; + unsigned long start; + unsigned long stop; + int cpu; +} per_cpu_test_driver[NR_CPUS]; + +static void shuffle_array(int *arr, int n) +{ + unsigned int rnd; + int i, j, x; + + for (i = n - 1; i > 0; i--) { + get_random_bytes(&rnd, sizeof(rnd)); + + /* Cut the range. */ + j = rnd % i; + + /* Swap indexes. */ + x = arr[i]; + arr[i] = arr[j]; + arr[j] = x; + } +} + +static int test_func(void *private) +{ + struct test_driver *t = private; + cpumask_t newmask = CPU_MASK_NONE; + int random_array[ARRAY_SIZE(test_case_array)]; + int index, i, j, ret; + ktime_t kt; + + cpumask_set_cpu(t->cpu, &newmask); + set_cpus_allowed_ptr(current, &newmask); + + for (i = 0; i < ARRAY_SIZE(test_case_array); i++) + random_array[i] = i; + + if (!sequential_test_order) + shuffle_array(random_array, ARRAY_SIZE(test_case_array)); + + /* + * Block until initialization is done. + */ + down_read(&prepare_for_test_rwsem); + + t->start = get_cycles(); + for (i = 0; i < ARRAY_SIZE(test_case_array); i++) { + index = random_array[i]; + + /* + * Skip tests if run_test_mask has been specified. + */ + if (!((run_test_mask & (1 << index)) >> index)) + continue; + + kt = ktime_get(); + for (j = 0; j < test_repeat_count; j++) { + ret = test_case_array[index].test_func(); + if (!ret) + per_cpu_test_data[t->cpu][index].test_passed++; + else + per_cpu_test_data[t->cpu][index].test_failed++; + } + + /* + * Take an average time that test took. + */ + per_cpu_test_data[t->cpu][index].time = + ktime_us_delta(ktime_get(), kt) / test_repeat_count; + } + t->stop = get_cycles(); + + up_read(&prepare_for_test_rwsem); + test_report_one_done(); + + /* + * Wait for the kthread_stop() call. + */ + while (!kthread_should_stop()) + msleep(10); + + return 0; +} + +static void +init_test_configurtion(void) +{ + /* + * Reset all data of all CPUs. + */ + memset(per_cpu_test_data, 0, sizeof(per_cpu_test_data)); + + if (single_cpu_test) + cpumask_set_cpu(cpumask_first(cpu_online_mask), + &cpus_run_test_mask); + else + cpumask_and(&cpus_run_test_mask, cpu_online_mask, + cpu_online_mask); + + if (test_repeat_count <= 0) + test_repeat_count = 1; + + if (test_loop_count <= 0) + test_loop_count = 1; +} + +static void do_concurrent_test(void) +{ + int cpu; + + /* + * Set some basic configurations plus sanity check. + */ + init_test_configurtion(); + + /* + * Put on hold all workers. + */ + down_write(&prepare_for_test_rwsem); + + for_each_cpu(cpu, &cpus_run_test_mask) { + struct test_driver *t = &per_cpu_test_driver[cpu]; + + t->cpu = cpu; + t->task = kthread_run(test_func, t, "vmalloc_test/%d", cpu); + + if (!IS_ERR(t->task)) + /* Success. */ + atomic_inc(&test_n_undone); + else + pr_err("Failed to start kthread for %d CPU\n", cpu); + } + + /* + * Now let the workers do their job. + */ + up_write(&prepare_for_test_rwsem); + + /* + * Sleep quiet until all workers are done. + */ + wait_for_completion(&test_all_done_comp); + + for_each_cpu(cpu, &cpus_run_test_mask) { + struct test_driver *t = &per_cpu_test_driver[cpu]; + int i; + + if (!IS_ERR(t->task)) + kthread_stop(t->task); + + for (i = 0; i < ARRAY_SIZE(test_case_array); i++) { + if (!((run_test_mask & (1 << i)) >> i)) + continue; + + pr_info( + "Summary: %s passed: %d failed: %d repeat: %d loops: %d avg: %llu usec\n", + test_case_array[i].test_name, + per_cpu_test_data[cpu][i].test_passed, + per_cpu_test_data[cpu][i].test_failed, + test_repeat_count, test_loop_count, + per_cpu_test_data[cpu][i].time); + } + + pr_info("All test took CPU%d=%lu cycles\n", + cpu, t->stop - t->start); + } +} + +static int vmalloc_test_init(void) +{ + do_concurrent_test(); + return -EAGAIN; /* Fail will directly unload the module */ +} + +static void vmalloc_test_exit(void) +{ +} + +module_init(vmalloc_test_init) +module_exit(vmalloc_test_exit) + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Uladzislau Rezki"); +MODULE_DESCRIPTION("vmalloc test module"); From patchwork Wed Jan 2 08:59:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 10746147 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4630F746 for ; Wed, 2 Jan 2019 08:59:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 365F52847E for ; Wed, 2 Jan 2019 08:59:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A4C528496; Wed, 2 Jan 2019 08:59:51 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BF252847E for ; Wed, 2 Jan 2019 08:59:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA25D8E0013; Wed, 2 Jan 2019 03:59:47 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DE5BD8E0002; Wed, 2 Jan 2019 03:59:47 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B46008E0013; Wed, 2 Jan 2019 03:59:47 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by kanga.kvack.org (Postfix) with ESMTP id 42E668E0002 for ; Wed, 2 Jan 2019 03:59:47 -0500 (EST) Received: by mail-lj1-f200.google.com with SMTP id f5-v6so8672678ljj.17 for ; Wed, 02 Jan 2019 00:59:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=rarOyscPiom4BfOyukPjF18EdM0Vr2KllAf9JRQ6xOs=; b=hRRWiK1wN847aQD9HYYvbTwJb09pvZr6So06zp5vsYQt/ZpqOXEgTAvCeCe4uj75jh ZwUwFLih0ORRfivjJusvGaUszk9G2YFHHjiZw47X8awOjVthfaK7CpdeJthKzCyNoGFx y4d0/ljGZTE6Ng7CMCH7iztvoXInOOyxMWHpFFa7uw3F9Ds0D+BiS4cnMs3rudHbrFhz uZQ75z8KOKeQ3eafXwbj04L5fcw0aGer/2xUpJ/y+jC6WMdopZRsxpnUxvdDtQrVK5FX zzwVW6J9PiPHfuDgHp/iGBm8EZRBSsYYHAhn9YushsPz4pKuroOfg2+zwztow2Zh0mms CgYg== X-Gm-Message-State: AJcUukfjB7zrFlAyDAAaK2i7hPSCFSGdW/Z+Z9/JGeZBix7Q8QUPCMud UDt2h3Og8icMMWujoNuVc3UlKZHIJM2rj8HD/08DeY3KV8zn0eKDzwdtRYj04ORsiJTzaEUhIe5 5AqmwJVzZr8W3R7A99ZLu38V149x8xI6PqgAJkGG8BoQ5JN/ogDI/9bDXgCMootPWjpfdOEUgQM txikTTQ2P/wDMByK/h+Mt5OeQyj8n5Fd9qUaixVA9By8Isn2qQdVg133BWGl0yb7fYuLIsW69Z5 yjpGlW5Mpktds+Mx8pM2GkCa+Fzb9ZRFC8g4gWK/Bj002K0bK4oFKZDoUfLZ9qLlP9rMZ9gm2tG W8fuTqLQ79zq0mt1Ne4iWdh74ZA8ObAO/JrTHL7FpUpBSoKcNbSWVA0S3ptvKZYHCk4VfbYwdb/ X X-Received: by 2002:a2e:9d8e:: with SMTP id c14-v6mr23560020ljj.146.1546419586556; Wed, 02 Jan 2019 00:59:46 -0800 (PST) X-Received: by 2002:a2e:9d8e:: with SMTP id c14-v6mr23559992ljj.146.1546419585311; Wed, 02 Jan 2019 00:59:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546419585; cv=none; d=google.com; s=arc-20160816; b=omaq3l2KDm6vO9Lrt9biRr+OUiSs4ZR7dQxeZC+TZ9L/HG1KK0ASchnXaLp421+2hf zj1XSJJ2IvTWwgpOLa/M6D0tRoWIeXMfxCBisE20u6MgsvkqI/YCvOVQGQYawBMywDK6 PrPT9Q4FYRz8Nv6dJQdOOulRaMx8T1C1dpllijUfSTXEY5WVV2leK88NwxDgjhne+wgX mq8eNCckXWe0VrG4sXL9xhacvceb4cT0vie6VuXF6oyZiJ5zfAG+m30JymNut6SLX25w YF5vq0AVvge+ZwjVE9i/VQyQU9cVdxgTx0q8Jfye1kD2q9orUVN95dE9J/nY0h87x7tA r/NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rarOyscPiom4BfOyukPjF18EdM0Vr2KllAf9JRQ6xOs=; b=GKehMmqfCBxoGe/ql/aiwT6R3wHtjuIR2NA2p9KpYx8AFTLHOKQAeYn3J3SWjWVi15 6HScfpeIoukGKvXqQBQO5oYjAEoSDPeBVsT6bf+a0mnlyPQEbGI363IWv2wf3qwNN0Eo z6vXEe/qGZupC/Iizm1P1LJZdY5q/o6NkkQh2+VB2mfYxV+mCJIXoVvUCb6dIZPzQKNE LC43Eiy+lkce2dVsIntueJChMPKITjqh4pHPBhfhbg/DUalZX9vXAjHKkypzkR66gLDz KKwl+vbYwmHtkyWLlk2ft+ealo2wwSDfzq0gWc2aYuNstSqVOmHx+TWXK22sMjqwmV4U vjhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hXMrUOnY; spf=pass (google.com: domain of urezki@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id u19sor12773625lfc.20.2019.01.02.00.59.45 for (Google Transport Security); Wed, 02 Jan 2019 00:59:45 -0800 (PST) Received-SPF: pass (google.com: domain of urezki@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hXMrUOnY; spf=pass (google.com: domain of urezki@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rarOyscPiom4BfOyukPjF18EdM0Vr2KllAf9JRQ6xOs=; b=hXMrUOnY5kfX6othwfgOCM1MWxpu49CBGcP7AmVOvFEbB7XiwDK+PR6KqVxQaEGg7y anPT/E+LSiXHSoCzZO7D/t2BPT5tr7geD/5ozb/6uMio8vh3NXSCzZK2/Cm6s39kpmKa Tua3Oz6YkZScDiZ30uZ2J4432iJ6Kp1JLMbcPeNCOZApc+rBZkKxNgOa7RMwvrxaGEPo JQgaggbmGDXtUKuxB4YhOtnBVslkHIrKD09nbnbnei8FENLLBlBRNCCpMKAj+gaNj0/q 7SWH+BTzJW5AiIb0Wv2BYZJ4TpWUZKWtWc3h3sQuaDJQOesKK9DnbNrgvKQ4KH+hcxjF qI8w== X-Google-Smtp-Source: AFSGD/UlF7IwT1L9rmiQG9sOiuefsgfcYqz2shl+JBnq0+GikF8jkxXvRK4hhzM9jimP6jmw3pkPUQ== X-Received: by 2002:a19:10a4:: with SMTP id 36mr20677421lfq.60.1546419584706; Wed, 02 Jan 2019 00:59:44 -0800 (PST) Received: from localhost.localdomain (mm-79-4-214-37.mogilev.dynamic.pppoe.byfly.by. [37.214.4.79]) by smtp.gmail.com with ESMTPSA id 10sm7489670ljr.4.2019.01.02.00.59.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Jan 2019 00:59:44 -0800 (PST) From: "Uladzislau Rezki (Sony)" To: Michal Hocko , Kees Cook , Shuah Khan , Andrew Morton , linux-mm@kvack.org Cc: LKML , Matthew Wilcox , Oleksiy Avramchenko , Thomas Gleixner , "Uladzislau Rezki (Sony)" Subject: [RFC v3 3/3] selftests/vm: add script helper for CONFIG_TEST_VMALLOC_MODULE Date: Wed, 2 Jan 2019 09:59:24 +0100 Message-Id: <20190102085924.14145-4-urezki@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190102085924.14145-1-urezki@gmail.com> References: <20190102085924.14145-1-urezki@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Add the test script for the kernel test driver to analyse vmalloc allocator for benchmarking and stressing purposes. It is just a kernel module loader. You can specify and pass different parameters in order to investigate allocations behaviour. See "usage" output for more details. Also add basic vmalloc smoke test to the "run_vmtests" suite. Signed-off-by: Uladzislau Rezki (Sony) --- tools/testing/selftests/vm/run_vmtests | 16 +++ tools/testing/selftests/vm/test_vmalloc.sh | 176 +++++++++++++++++++++++++++++ 2 files changed, 192 insertions(+) create mode 100755 tools/testing/selftests/vm/test_vmalloc.sh diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests index 88cbe5575f0c..48ac0f757e9c 100755 --- a/tools/testing/selftests/vm/run_vmtests +++ b/tools/testing/selftests/vm/run_vmtests @@ -200,4 +200,20 @@ else echo "[PASS]" fi +echo "------------------------------------" +echo "running vmalloc stability smoke test" +echo "------------------------------------" +./test_vmalloc.sh smoke +ret_val=$? + +if [ $ret_val -eq 0 ]; then + echo "[PASS]" +elif [ $ret_val -eq $ksft_skip ]; then + echo "[SKIP]" + exitcode=$ksft_skip +else + echo "[FAIL]" + exitcode=1 +fi + exit $exitcode diff --git a/tools/testing/selftests/vm/test_vmalloc.sh b/tools/testing/selftests/vm/test_vmalloc.sh new file mode 100755 index 000000000000..06d2bb109f06 --- /dev/null +++ b/tools/testing/selftests/vm/test_vmalloc.sh @@ -0,0 +1,176 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (C) 2018 Uladzislau Rezki (Sony) +# +# This is a test script for the kernel test driver to analyse vmalloc +# allocator. Therefore it is just a kernel module loader. You can specify +# and pass different parameters in order to: +# a) analyse performance of vmalloc allocations; +# b) stressing and stability check of vmalloc subsystem. + +TEST_NAME="vmalloc" +DRIVER="test_${TEST_NAME}" + +# 1 if fails +exitcode=1 + +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + +# +# Static templates for performance, stressing and smoke tests. +# Also it is possible to pass any supported parameters manualy. +# +PERF_PARAM="single_cpu_test=1 sequential_test_order=1 test_repeat_count=3" +SMOKE_PARAM="single_cpu_test=1 test_loop_count=10000 test_repeat_count=10" +STRESS_PARAM="test_repeat_count=20" + +check_test_requirements() +{ + uid=$(id -u) + if [ $uid -ne 0 ]; then + echo "$0: Must be run as root" + exit $ksft_skip + fi + + if ! which modprobe > /dev/null 2>&1; then + echo "$0: You need modprobe installed" + exit $ksft_skip + fi + + if ! modinfo $DRIVER > /dev/null 2>&1; then + echo "$0: You must have the following enabled in your kernel:" + echo "CONFIG_TEST_VMALLOC=m" + exit $ksft_skip + fi +} + +run_perfformance_check() +{ + echo "Run performance tests to evaluate how fast vmalloc allocation is." + echo "It runs all test cases on one single CPU with sequential order." + + modprobe $DRIVER $PERF_PARAM > /dev/null 2>&1 + echo "Done." + echo "Ccheck the kernel message buffer to see the summary." +} + +run_stability_check() +{ + echo "Run stability tests. In order to stress vmalloc subsystem we run" + echo "all available test cases on all available CPUs simultaneously." + echo "It will take time, so be patient." + + modprobe $DRIVER $STRESS_PARAM > /dev/null 2>&1 + echo "Done." + echo "Check the kernel ring buffer to see the summary." +} + +run_smoke_check() +{ + echo "Run smoke test. Note, this test provides basic coverage." + echo "Please check $0 output how it can be used" + echo "for deep performance analysis as well as stress testing." + + modprobe $DRIVER $SMOKE_PARAM > /dev/null 2>&1 + echo "Done." + echo "Check the kernel ring buffer to see the summary." +} + +usage() +{ + echo -n "Usage: $0 [ performance ] | [ stress ] | | [ smoke ] | " + echo "manual parameters" + echo + echo "Valid tests and parameters:" + echo + modinfo $DRIVER + echo + echo "Example usage:" + echo + echo "# Shows help message" + echo "./${DRIVER}.sh" + echo + echo "# Runs 1 test(id_1), repeats it 5 times on all online CPUs" + echo "./${DRIVER}.sh run_test_mask=1 test_repeat_count=5" + echo + echo -n "# Runs 4 tests(id_1|id_2|id_4|id_16) on one CPU with " + echo "sequential order" + echo -n "./${DRIVER}.sh single_cpu_test=1 sequential_test_order=1 " + echo "run_test_mask=23" + echo + echo -n "# Runs all tests on all online CPUs, shuffled order, repeats " + echo "20 times" + echo "./${DRIVER}.sh test_repeat_count=20" + echo + echo "# Performance analysis" + echo "./${DRIVER}.sh performance" + echo + echo "# Stress testing" + echo "./${DRIVER}.sh stress" + echo + exit 0 +} + +function validate_passed_args() +{ + VALID_ARGS=`modinfo $DRIVER | awk '/parm:/ {print $2}' | sed 's/:.*//'` + + # + # Something has been passed, check it. + # + for passed_arg in $@; do + key=${passed_arg//=*/} + val="${passed_arg:$((${#key}+1))}" + valid=0 + + for valid_arg in $VALID_ARGS; do + if [[ $key = $valid_arg ]] && [[ $val -gt 0 ]]; then + valid=1 + break + fi + done + + if [[ $valid -ne 1 ]]; then + echo "Error: key or value is not correct: ${key} $val" + exit $exitcode + fi + done +} + +function run_manual_check() +{ + # + # Validate passed parameters. If there is wrong one, + # the script exists and does not execute further. + # + validate_passed_args $@ + + echo "Run the test with following parameters: $@" + modprobe $DRIVER $@ > /dev/null 2>&1 + echo "Done." + echo "Check the kernel ring buffer to see the summary." +} + +function run_test() +{ + if [ $# -eq 0 ]; then + usage + else + if [[ "$1" = "performance" ]]; then + run_perfformance_check + elif [[ "$1" = "stress" ]]; then + run_stability_check + elif [[ "$1" = "smoke" ]]; then + run_smoke_check + else + run_manual_check $@ + fi + fi +} + +check_test_requirements +run_test $@ + +exit 0