Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3294207imu; Mon, 17 Dec 2018 17:22:28 -0800 (PST) X-Google-Smtp-Source: AFSGD/XqtpKs6wG6iAtetNifyJTNjXWjsJJinjpQ4KcBk/gYDaSwEsSlzhQfQnT0L8X0klPWEWmE X-Received: by 2002:a65:5c4b:: with SMTP id v11mr14011822pgr.333.1545096148908; Mon, 17 Dec 2018 17:22:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545096148; cv=none; d=google.com; s=arc-20160816; b=ZyjmtXCAb0m0xvaLCDZKwvK+Zek9wyyTG3D62Sg5BuaQIq4Eh++PF16pB/05Lcm5iA LGltcBNnf3UP8ZPwDQgriXTuHJxLXxiAkACQkNmUk4TMt5oHXC9B9MLsg1mHd6SYrkzz 6qtaE7EhHlLWiY1+lnqbs8NDt1xBR30B0/C0DGmC3jqM/DNku7nOT4fa+chjAV+tlsbh RsJe/sWSggmwTopyB0di/Kkza8QOaj8UA9wMeO24cqPLkEe8y+7NXLN/LZsXTSEbty1H NHJjt1hEUzJdMFycRT+JdwGRN9bNMSwwp3LfBLR8ML9glAQhQqpNO0oYRuCsdzaIvNBp GBTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=mbu7X9AToTNe0+9pY+V/zik+z11jPPNgr5XbogPquck=; b=n0FJSvYt1AizVgw7w5Z0BnMLztwyi7m8r5cminehTyRwDa4+JQBJtYofSERd6QBErs RN4a9rngq8zuBfoOF3tecFsK30FYt18J3/E8MUOkjDPXFKqaFOE3Dp+TiqRpAY9Kby4t J7mhL1b2AtmVH4N7UdaxgkNpdE02xeF+bDUTlD49Gju+tvt/1u6DYOqirX7NjOCYtZS8 8U1km/kIiYEz+bqfsTe+1stL3xYbLA+PourzN3T/1S++NK3Si8q1CMk7mWYejma7OEk3 OYL78Ce/e6d7Ktuw0xjnSgm/vlvEBQ9yggurtNKs7VaPMPotRAj2UEicAscBGIFaKmyf j1Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=coXf01at; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y1si1029813plt.356.2018.12.17.17.22.12; Mon, 17 Dec 2018 17:22:28 -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=@google.com header.s=20161025 header.b=coXf01at; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726324AbeLRBVU (ORCPT + 99 others); Mon, 17 Dec 2018 20:21:20 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:52722 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726276AbeLRBVT (ORCPT ); Mon, 17 Dec 2018 20:21:19 -0500 Received: by mail-wm1-f65.google.com with SMTP id m1so1027043wml.2 for ; Mon, 17 Dec 2018 17:21:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mbu7X9AToTNe0+9pY+V/zik+z11jPPNgr5XbogPquck=; b=coXf01atRsTDqmB60HaGrMfJ9f0HsjrT+OHvDJEcfrJamR18DOV+C7fFynNk2ez9SJ BKSH1/oXnxflTvNhg+cGiL7yWVnj2Zg4e3QNNWlkYdCVMXHb43eZnhdyZOKXEi66v+RI HbljguhNMbi9EKkecWaukYVNcgrqph1g9k+fFNtG/EGhk9GizfS+fGgSN2p+Q+2PkFry kY20M9dCRj/bSHJZrgrAMFb/pnNcUyHC5iIWkM57w4hvflFBtOxRZhIvwdHzRUQ/kfLF JEPAfSUjM3ZhQK3CmnONs/7pVi7e5yHMB7jY8US8eK6M6y8iqmLkPsYLXVj7fTi8/b70 BDEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mbu7X9AToTNe0+9pY+V/zik+z11jPPNgr5XbogPquck=; b=bjDoaeqVH9F1n6UiMdVO8p0tAJ0v/pXiVBUMy1hMMO0zMLUFzm4Ka0a99XRoVTAol9 E1BnTFGNxkljSE5mYIisTkqLqcw5G4k6QEQ8dNI+3eIfo4Db2xIgglbMUIKrGG68+klV V3qV9K9bu/o0Y/Q/fUmcQsm1XPtbgivwdIIMfXVpl+RnLuhC6/6dsD2n5n/qDDFVJqXu k0MqOc/YQxbURg6jr1qlROtCMMUF2fzsUeMSnSNxcCwKhmTFu4LzgFYdFaNk2aAcuvlh NiBbRpvqnA1hJqzjRcWwEDEuVlMFHvdUeschgyIG0bIaTOg1hamXy/eRy90Z1cwhRCsn pKgA== X-Gm-Message-State: AA+aEWb9tK7AE9pFt0VYvBL5OzHzJCKlYTbaYz17SYT3n0ZL22WN8u2n iqrCVs5oPxtrGEe1qYRMjhjybLGQ3I60aoRI0w9X1g== X-Received: by 2002:a1c:1286:: with SMTP id 128mr1187179wms.70.1545096076972; Mon, 17 Dec 2018 17:21:16 -0800 (PST) MIME-Version: 1.0 References: <20181214171508.7791-1-surenb@google.com> <20181214171508.7791-7-surenb@google.com> <20181217162223.GD2218@hirez.programming.kicks-ass.net> In-Reply-To: <20181217162223.GD2218@hirez.programming.kicks-ass.net> From: Suren Baghdasaryan Date: Mon, 17 Dec 2018 17:21:05 -0800 Message-ID: Subject: Re: [PATCH 6/6] psi: introduce psi monitor To: Peter Zijlstra Cc: Greg Kroah-Hartman , Tejun Heo , lizefan@huawei.com, Johannes Weiner , axboe@kernel.dk, dennis@kernel.org, Dennis Zhou , Ingo Molnar , Andrew Morton , Jonathan Corbet , cgroups@vger.kernel.org, linux-mm , linux-doc@vger.kernel.org, LKML , kernel-team@android.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 17, 2018 at 8:22 AM Peter Zijlstra wrote: > > On Fri, Dec 14, 2018 at 09:15:08AM -0800, Suren Baghdasaryan wrote: > > +ssize_t psi_trigger_parse(char *buf, size_t nbytes, enum psi_res res, > > + enum psi_states *state, u32 *threshold_us, u32 *win_sz_us) > > +{ > > + bool some; > > + bool threshold_pct; > > + u32 threshold; > > + u32 win_sz; > > + char *p; > > + > > + p = strsep(&buf, " "); > > + if (p == NULL) > > + return -EINVAL; > > + > > + /* parse type */ > > + if (!strcmp(p, "some")) > > + some = true; > > + else if (!strcmp(p, "full")) > > + some = false; > > + else > > + return -EINVAL; > > + > > + switch (res) { > > + case (PSI_IO): > > + *state = some ? PSI_IO_SOME : PSI_IO_FULL; > > + break; > > + case (PSI_MEM): > > + *state = some ? PSI_MEM_SOME : PSI_MEM_FULL; > > + break; > > + case (PSI_CPU): > > + if (!some) > > + return -EINVAL; > > + *state = PSI_CPU_SOME; > > + break; > > + default: > > + return -EINVAL; > > + } > > + > > + while (isspace(*buf)) > > + buf++; > > + > > + p = strsep(&buf, "%"); > > + if (p == NULL) > > + return -EINVAL; > > + > > + if (buf == NULL) { > > + /* % sign was not found, threshold is specified in us */ > > + buf = p; > > + p = strsep(&buf, " "); > > + if (p == NULL) > > + return -EINVAL; > > + > > + threshold_pct = false; > > + } else > > + threshold_pct = true; > > + > > + /* parse threshold */ > > + if (kstrtouint(p, 0, &threshold)) > > + return -EINVAL; > > + > > + while (isspace(*buf)) > > + buf++; > > + > > + p = strsep(&buf, " "); > > + if (p == NULL) > > + return -EINVAL; > > + > > + /* Parse window size */ > > + if (kstrtouint(p, 0, &win_sz)) > > + return -EINVAL; > > + > > + /* Check window size */ > > + if (win_sz < PSI_TRIG_MIN_WIN_US || win_sz > PSI_TRIG_MAX_WIN_US) > > + return -EINVAL; > > + > > + if (threshold_pct) > > + threshold = (threshold * win_sz) / 100; > > + > > + /* Check threshold */ > > + if (threshold == 0 || threshold > win_sz) > > + return -EINVAL; > > + > > + *threshold_us = threshold; > > + *win_sz_us = win_sz; > > + > > + return 0; > > +} > > How well has this thing been fuzzed? Custom string parser, yay! Honestly, not much. Normal cases and some obvious corner cases. Will check if I can use some fuzzer to get more coverage or will write a script. I'm not thrilled about writing a custom parser, so if there is a better way to handle this please advise. > -- > You received this message because you are subscribed to the Google Groups "kernel-team" group. > To unsubscribe from this group and stop receiving emails from it, send an email to kernel-team+unsubscribe@android.com. >