Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1595239rdb; Mon, 2 Oct 2023 14:51:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHNLXtqNwSjjezvsI6QH5OWhBqSUkMOcmXQAM1ahpKSVk+YaI5k6gFfY9WIYqINIIt77as9 X-Received: by 2002:a05:6808:1291:b0:3a8:6693:135d with SMTP id a17-20020a056808129100b003a86693135dmr17515217oiw.49.1696283519506; Mon, 02 Oct 2023 14:51:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696283519; cv=none; d=google.com; s=arc-20160816; b=I0VII+90WWP5lWGZEWTDKgoMVoKDJEhc2G+c0edwFpC4colTp9ygMbGW3h8NtQYBqt +w54DqZ7dN1pCDTltrzugIjZCoxaQ4qVJE+24LBMCFnHXWSkiMXScC3eRh0Xusr+yHiA yQIksbw1WP8n8a0xkT5x0a/JGb+QWztNR2CQMyeaXsDPM1yMo9+b9TqytK3YVHmJp7Fr 1Mx3d39aEMTtS5UP4FNMhxNkR+QpIh3nS8fSNqYhAblxFzoytlV4L9s5sXTJaq0N29QA NOpebXV14Lrb21SE0Cu/ERF4K4S2/+ChGncpZEIi6kmcqyRjpMQ6znJF9Xkdx6B32lD9 lPnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=t0XqXLw8ahxmmww8UtIigy7ye9qRf79OVR4xxbkYhI4=; fh=uyUWPxjYS0/3SbkDyygAQY2x7TabusfAeO09rIxENpw=; b=WfR19Y9he0WynnJYZYUGthtL1rGX8noxLP/jUfYTf9xxlNFbVMozgMfCcKtil+a2b7 9sCQAeNh5x222gpmcJxcgthKOasB1dx0/SBB/QhqHkFU7czJ/T9XvWeJEbA/a1nLD2xM H/ukxUbeZfJQ0Y3j3xR/+ns5Z4/XoA6nZbCRkCsJJszopB41OOAXhjT3LFDtUQ2+l/Wt 4IxnPgJNqgpegPZaoG1Vw+vWag0lZ/rYeIC5+hSVukB+EgWneeovg1CyJBitVSkZzTt5 L6SSqAW6XTCg12XFtv+6Zd3vmY+3dzU0WF5f6YqThszS40C1pW1tEQpls2tvdU9fTVIZ Tggw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QnIyC0bv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id d19-20020a637353000000b00577f80ddb2esi28361178pgn.705.2023.10.02.14.51.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 14:51:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QnIyC0bv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 7ADD98085F80; Mon, 2 Oct 2023 05:38:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237123AbjJBMig (ORCPT + 99 others); Mon, 2 Oct 2023 08:38:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237115AbjJBMif (ORCPT ); Mon, 2 Oct 2023 08:38:35 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33675AC for ; Mon, 2 Oct 2023 05:38:30 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-5333fb34be3so21849354a12.1 for ; Mon, 02 Oct 2023 05:38:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696250308; x=1696855108; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=t0XqXLw8ahxmmww8UtIigy7ye9qRf79OVR4xxbkYhI4=; b=QnIyC0bv/pew6OLIdxi8ly1dChu5u/eBT3hFH35GH+eb8hpMOYyvsixm6OLaeWralM Sdw+w3Ue6XsvEYD4zxpLngNHa30DEO+qZUjUmI3rznH9toHiyG8DEIsSXiSckbANy4QM fxfVkEIomIbCa2AMAGNIIBU1IPcVype/u5A+39GBNmhjEhjpvZbQcJ08PGicEiQM6Bgz 2PV6SvENuFXnusdKiCSUzq/z4S3KrushAzhTCMnc/oZnVMm7WE0N2w2zB514KzkbmUdR z5t43u7COaFr90auT7i109+cSfUNfqUv5rLeDIO1bzDH2RIhAhcowtWzTBgX93yCx45/ 88VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696250308; x=1696855108; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=t0XqXLw8ahxmmww8UtIigy7ye9qRf79OVR4xxbkYhI4=; b=cKCi2FFzTK0Rjs5+fm9PHv4cDq0OarNWxrbhy2ehozr/+OiSdzXa/CrPHMyVh/5Uai ao1UngImTNzSqLrOSctNcwHygGjizEfaDcDVWijzukEzAxInH69YBPlnmYRHTCCLcuBO agTWF7A9kHJuKrFfNKvrinEBUf65s330wtatnpqU5JWda63nvGiAUaX2F373uhj0VvdT Kb3RMjfV9x41uFdhJg8WovXZLlw9Oprq5ywL7Fai4/qlwZ3AquH5CrE2R0HZFQJque0d TXQ9n4GKYkQIJ0pUsXc7Oti47qe6/V1j5REbm+PuddbvuK9FkBZ9p7bUsLFQ2i/KdWgJ lDQg== X-Gm-Message-State: AOJu0YyJEVnxXkGumRIFw5fYU5AYLIt5OXqK2f44yAz/5EPeY2kdWjkA TYF4T8pn5CmpgoqiAJ7bO6gobPAgXw== X-Received: by 2002:a17:906:319b:b0:99d:e617:abeb with SMTP id 27-20020a170906319b00b0099de617abebmr10034329ejy.23.1696250308302; Mon, 02 Oct 2023 05:38:28 -0700 (PDT) Received: from p183 ([46.53.251.182]) by smtp.gmail.com with ESMTPSA id l15-20020a1709067d4f00b009920a690cd9sm16955339ejp.59.2023.10.02.05.38.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 05:38:27 -0700 (PDT) Date: Mon, 2 Oct 2023 15:38:25 +0300 From: Alexey Dobriyan To: Andrew Morton Cc: linux-kernel@vger.kernel.org, shuah@kernel.org, hughd@google.com, swarupkotikalapudi@gmail.com Subject: Re: + selftests-proc-add-proc-pid-statm-output-validation.patch added to mm-nonmm-unstable branch Message-ID: References: <20231001193740.B716AC433C7@smtp.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231001193740.B716AC433C7@smtp.kernel.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 02 Oct 2023 05:38:37 -0700 (PDT) On Sun, Oct 01, 2023 at 12:37:40PM -0700, Andrew Morton wrote: > selftests-proc-add-proc-pid-statm-output-validation.patch > Add /proc/${pid}/statm validation > > /proc/$(pid)/statm output is expected to be: > "0 0 0 * 0 0 0\n" > Here * can be any value > > Read output of /proc/$(pid)/statm > and compare length of output is > equal or greater than expected output > --- a/tools/testing/selftests/proc/proc-empty-vm.c~selftests-proc-add-proc-pid-statm-output-validation > +++ a/tools/testing/selftests/proc/proc-empty-vm.c > @@ -303,6 +303,37 @@ static int test_proc_pid_smaps_rollup(pi > } > } > > +static const char g_statm[] = "0 0 0 * 0 0 0\n"; This is both unreliable and incorrect. 4th value is "end_code - start_code" when exec is done which could be anything not 1-digit number (although unlikely). Testing for strlen is simply too weak of a test. > +static int test_proc_pid_statm(pid_t pid) > +{ > + char buf[4096]; > + > + snprintf(buf, sizeof(buf), "/proc/%u/statm", pid); > + > + int fd = open(buf, O_RDONLY); > + > + if (fd == -1) { > + if (errno == ENOENT) { > + /* > + * /proc/${pid}/statm is under CONFIG_PROC_PAGE_MONITOR, > + * it doesn't necessarily exist. > + */ > + return EXIT_SUCCESS; > + } > + perror("open /proc/${pid}/statm"); > + return EXIT_FAILURE; > + } else { > + ssize_t rv = read(fd, buf, sizeof(buf)); > + > + close(fd); > + size_t len = strlen(g_statm); > + > + assert(rv >= len); > + return EXIT_SUCCESS; > + } > +} > + > int main(void) > { > int rv = EXIT_SUCCESS; > @@ -389,11 +420,8 @@ int main(void) > if (rv == EXIT_SUCCESS) { > rv = test_proc_pid_smaps_rollup(pid); > } > - /* > - * TODO test /proc/${pid}/statm, task_statm() > - * ->start_code, ->end_code aren't updated by munmap(). > - * Output can be "0 0 0 2 0 0 0\n" where "2" can be anything. > - */ > + if (rv == EXIT_SUCCESS) > + rv = test_proc_pid_statm(pid); > > /* Cut the rope. */