From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAB64E7C4F4 for ; Wed, 4 Oct 2023 20:17:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233433AbjJDURG (ORCPT ); Wed, 4 Oct 2023 16:17:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232977AbjJDURF (ORCPT ); Wed, 4 Oct 2023 16:17:05 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F4DE93 for ; Wed, 4 Oct 2023 13:17:02 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87CB5C433C7; Wed, 4 Oct 2023 20:17:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1696450621; bh=cdjazfbp8Pz0orhe+iGwTWziknZjJcPZxbxU2sniEC4=; h=Date:To:From:Subject:From; b=kg+vfXgY8msEC+tVF2hbzRHFtxhkqeiOPhAoHzPVQopfik/fvYiX2SWEIm8Um7GqM aE10dmWbdiaKxeCYJvvnR3YsDDbWdFIeoF+CRBeTDhiBWY7+aW1WUw/hPV0cI9L8J4 8wa29CBmWY2egZJPNqvak5HGz104Cc1emCv4V0I4= Date: Wed, 04 Oct 2023 13:17:00 -0700 To: mm-commits@vger.kernel.org, shuah@kernel.org, hughd@google.com, adobriyan@gmail.com, swarupkotikalapudi@gmail.com, akpm@linux-foundation.org From: Andrew Morton Subject: + selftests-proc-add-proc-pid-statm-output-validation.patch added to mm-nonmm-unstable branch Message-Id: <20231004201701.87CB5C433C7@smtp.kernel.org> Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org The patch titled Subject: selftests: proc: add /proc/$(pid)/statm output validation has been added to the -mm mm-nonmm-unstable branch. Its filename is selftests-proc-add-proc-pid-statm-output-validation.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/selftests-proc-add-proc-pid-statm-output-validation.patch This patch will later appear in the mm-nonmm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Swarup Laxman Kotiaklapudi Subject: selftests: proc: add /proc/$(pid)/statm output validation Date: Wed, 4 Oct 2023 01:13:19 +0530 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 check except for 4th position, all other positions have value zero. Link: https://lkml.kernel.org/r/20231003194319.602646-1-swarupkotikalapudi@gmail.com Signed-off-by: Swarup Laxman Kotiaklapudi Cc: Alexey Dobriyan Cc: Hugh Dickins Cc: Shuah Khan Signed-off-by: Andrew Morton --- tools/testing/selftests/proc/proc-empty-vm.c | 57 +++++++++++++++-- 1 file changed, 52 insertions(+), 5 deletions(-) --- 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,56 @@ static int test_proc_pid_smaps_rollup(pi } } +static int test_proc_pid_statm(pid_t pid) +{ + char buf[4096]; + char *tok; + char *string; + int non_zero_value_indx = 4; + int i = 1; + + snprintf(buf, sizeof(buf), "/proc/%u/statm", pid); + + /* + * Output can be "0 0 0 2 0 0 0\n" where "2" can be anything. + */ + 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); + assert(rv); + string = buf; + + while ((tok = strsep(&string, " ")) != NULL) { + if (i == non_zero_value_indx) { + if (!strncmp(tok, "0", 1)) + goto err_statm; + } else { + if (strncmp(tok, "0", 1)) + goto err_statm; + } + i++; + } + } + + return EXIT_SUCCESS; + +err_statm: + assert(0); +} + int main(void) { int rv = EXIT_SUCCESS; @@ -389,11 +439,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. */ int wstatus; _ Patches currently in -mm which might be from swarupkotikalapudi@gmail.com are selftests-proc-add-proc-pid-statm-output-validation.patch