Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp326241imp; Wed, 20 Feb 2019 00:37:50 -0800 (PST) X-Google-Smtp-Source: AHgI3IYSbGi6G2NTl8lR0N3yLWWtk2S1W4ub+sN7RceKZOJ0yzdBpsgYOPw5rEqcW251q9K/XGCe X-Received: by 2002:a63:9dc3:: with SMTP id i186mr31841643pgd.305.1550651870579; Wed, 20 Feb 2019 00:37:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550651870; cv=none; d=google.com; s=arc-20160816; b=AVvZD2vV89nkAo/lNal6Xm0w5QbS3E+oDJuzM4Bt8IfiEd+jV/tGGhsoimhiiAYrWA yqqi4wKjeN6fQu/bsuYUshrlfpunOKA1URiK2OQ24VSZt4qQrWYVcB0GoQUPDZd7clgq p4awnMLhamzgfRkimx0h0ghQJW9p7gAiUH50QDyTLx8YAOomI9Z337rJBmk0K4Bkvjey XNiee8h6/U2ormAPuUulRYNry2ZVEyiLMBXtbfgc8MDfMeFQ5am/JMJR1Wpgpydtnn5C 6gLw+TUmHr3bIrZnmCe3Ag+lxIeSgZd58jdW3TdqEqyJs4Irf8ZPlgoeVX0Uyp/Ye8eh 24Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=kGc2Cd4sVzbxMZBKfCCn20jYLojVNMmuJ1uQuDd9OoY=; b=ADC5Zyo/kwJlB/LcO8jWppHWbL2TKYP/uW524eyVXC0IMFVCwV9MxpJ8zC8sT8H6zo k4jKoTDZao4m6y1LdhzobUc01YtpXnWvCvLhJGBZhGqRhFACVsYxPb5jGdg1yQeTyzjH x7OxhX6Ic3MDBtMRCtGjeYmY2LS3MAPUG0vfxya4cTYGfTPwLty8Peghj0wWW/tWGASv wMZxCyWKU0v4L5pNT5xzwlWfLnRQS7NrucnkhWWnnV3XzPnzOHkB5OmXtpP2C3NC9XjH nXkNC1RuSCXh6vw4jmnQ8T+sSV9i9FgnJ0j+M4eDYHLI4waHPlL/suyfTnAAFnYi2Nej YlyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="S/ELlh1G"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d65si18400866pfc.201.2019.02.20.00.37.35; Wed, 20 Feb 2019 00:37:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="S/ELlh1G"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726142AbfBTIhN (ORCPT + 99 others); Wed, 20 Feb 2019 03:37:13 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:42806 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725846AbfBTIhM (ORCPT ); Wed, 20 Feb 2019 03:37:12 -0500 Received: by mail-lf1-f67.google.com with SMTP id l10so16903736lfh.9 for ; Wed, 20 Feb 2019 00:37:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=kGc2Cd4sVzbxMZBKfCCn20jYLojVNMmuJ1uQuDd9OoY=; b=S/ELlh1GSFPyd7a01ReujYHYB4oUtNvQM0mjRFi9Fhn1yJOYorz4ubdoNxShRuzz0L siR0cTjoBvhn7SqR7m3q1T8zwR+VrOg+YKVqgkIj/RZZjRE0t93RYBSqlk/6JDHhl2lq SHVB3xQzXNv95hseKxtFWcqMOnv1Iq6oQ2ZNT1PHbeZkVSnaql9V/Vyrh0x9dsPfMixN bgixfG+bmLlfePSyWUWtN6lftgCkDVJRpka3I7AKliwWuCvxc83QQ2PbizTpBMnsWN85 ogoW0KLRTgLQR31KN7QBqoLO45mk265MQFFn3lnWULx4U44rF3pHbS5DPDJ188xfxgRT t+cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=kGc2Cd4sVzbxMZBKfCCn20jYLojVNMmuJ1uQuDd9OoY=; b=cYH+HnF8OsEk2y0Zi8ij5T1KGRg+UPeKDWBQ4aX1eu5T84LKwfVIrpb5Xt9xqVy34W m9/aGW3cUBAQjbJwYghqgOTeSvGMrWk+DKpQRFU770duSvDx4vJcQKqjFv05uq41LV6p I2wLkfGTUqwYcoXIQBHt8gr5eK7rHyPddHOXGv+LmYtBczKgWSfKfR4dtoQw+bgJYzYo +qyLNE53mFNiu+AqGZQzJyjs2doc7YuywhMuV8PYqw8qmKVa6peubQnmbOB4EPBSNMDO G/bV+LauUkTVsPzbEZ+JJi/cyYDK4nQ2O79vep/XdKMjbcSLJ/dDaBcWidZG/t8y1AoI S6Kg== X-Gm-Message-State: AHQUAuanUkd+/5tARDnxHNZjgrBDSmrRNdgmeOnFZhWaEie4zjKI28kC 2HX4Y0ubI29LdOMCV1sEBLg= X-Received: by 2002:ac2:4243:: with SMTP id m3mr19062128lfl.5.1550651830605; Wed, 20 Feb 2019 00:37:10 -0800 (PST) Received: from localhost ([188.162.52.148]) by smtp.gmail.com with ESMTPSA id q15sm1982118lje.89.2019.02.20.00.37.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Feb 2019 00:37:09 -0800 (PST) From: Yury Norov X-Google-Original-From: Yury Norov To: Andrew Morton , Andy Shevchenko , Arnd Bergmann , Dmitry Torokhov , Kees Cook , Matthew Wilcox , Michael Ellerman , Rasmus Villemoes , Tetsuo Handa Cc: Yury Norov , linux-kernel@vger.kernel.org, Yury Norov Subject: [PATCH v2 0/5] lib: rework bitmap_parselist and tests Date: Wed, 20 Feb 2019 11:36:59 +0300 Message-Id: <20190220083705.14050-1-ynorov@marvell.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org bitmap_parselist has been evolved from a pretty simple idea for long and now lacks for refactoring. It is not structured, has nested loops and a set of opaque-named variables. All this leads to extremely hard understanding of the code. Once during the optimization of it I missed a scenario which leads to kernel hangup. Tetsuo Handa spotted this and found it simpler to rewrite the code instead fixing it. (Though, that attempt had some flaws.) https://lkml.org/lkml/2018/4/1/93 Things are more complicated than they may be because bitmap_parselist() is part of user interface, and its behavior should not change. In this patchset - __bitmap_parselist() is reworked (patches 2 and 3); - time measurement in test_bitmap_parselist switched to ktime_get (patch 4); - new tests introduced (patch 5), and - bitmap_parselist_user() testing enabled with the same testset as bitmap_parselist() (patch 6). Patch 1 is a fix and may be applied separately. V1: https://lkml.org/lkml/2018/12/23/50 v2: - use PTR_ERR() and ERR_PTR() where appropriate; - fix parser logic (last byte of string handling); - tests for bitmap_parselist_user() in patch 5. Yury Norov (4): bitmap_parselist: don't calculate length of the input string bitmap_parselist: move non-parser logic to helpers bitmap_parselist: rework input string parser lib/test_bitmap: switch test_bitmap_parselist to ktime_get() lib/test_bitmap: add testcases for bitmap_parselist lib/test_bitmap: add tests for bitmap_parselist_user lib/bitmap.c | 293 ++++++++++++++++++++++++++++++---------------- lib/test_bitmap.c | 67 +++++++++-- 2 files changed, 245 insertions(+), 115 deletions(-) -- 2.17.1