From nobody Thu Nov 14 02:21:24 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XpkRk4Y9fz5cwBX; Thu, 14 Nov 2024 02:21:38 +0000 (UTC) (envelope-from jlduran@gmail.com) Received: from mail-yb1-f180.google.com (mail-yb1-f180.google.com [209.85.219.180]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XpkRj13Phz48L4; Thu, 14 Nov 2024 02:21:37 +0000 (UTC) (envelope-from jlduran@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=none; spf=pass (mx1.freebsd.org: domain of jlduran@gmail.com designates 209.85.219.180 as permitted sender) smtp.mailfrom=jlduran@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=freebsd.org (policy=none) Received: by mail-yb1-f180.google.com with SMTP id 3f1490d57ef6-e2bd1bbaf03so20923276.2; Wed, 13 Nov 2024 18:21:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731550896; x=1732155696; h=content-transfer-encoding:cc:to:subject:message-id:date:from :reply-to:in-reply-to:references:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=5bAyygh2TYBw+2xBJ2yf5RVL4jkiOPMwxcmOAhuY0BQ=; b=qAFg9pCyjzxAZ972G9mAbwhzwGP1sgo+OoO8px+gGHeoqya9SJQ4dNjWn2ci2JU002 qFNzNLatMPA0IbgGEP7dFl0lQiUNSnJ5EeFsAyoq16vdkXo9TU0CRVBBLKu6CJOvATHI JwyPK3rPWMrhsHKG/91nEN98FHASxBmwknxooTc/n5azJmJsPg3h36zDkIwiqhtIjzsJ wmK1YPn4QhSXVOtAWeRntN598MUvdd51+GLfu6JhXaZBNolDTds9AgB8ZE8eE+JiLIX3 XvnO4lepuifkq3a/qwwCYdQpF/sx2vMa75MorR37UPjXuEthh0+fDdlcXJI898j9MnjM zO8g== X-Forwarded-Encrypted: i=1; AJvYcCV0bxMTFlFt0papspZ7ys9RXUZuGVFIwLRpy5LZiF/qK3dGi90yVTHCAU96EgYwEOdrQM688GkATN43T6NmK94+Wyjw@freebsd.org, AJvYcCV7YIHbk1Lrrg68iamSHlQTb7YkEycGu5wgWVjxFIRFwUK3Hd1e9e3TmW2vEsTf3/fEC8Z5Z+HxB/JvfhidmOZKEX9CR/I=@freebsd.org X-Gm-Message-State: AOJu0YymQSOdqT4sBjJ+FoKn6mZdl4i8eoWmouy+5I224NkfVUNhnCh2 jf5keIUAU/gTJhBjP8ji2xTu0wYynLUs4i3gDK3BiDwHmgeYMl+wjtSTL8wo X-Google-Smtp-Source: AGHT+IEerycBfLEEH4eQ4orQJnvIMs42nc9jc8Evqm2nzdCf5yV+D4i5umJkFKvaznxKlM/mtxZHkw== X-Received: by 2002:a25:ae50:0:b0:e38:1230:45c4 with SMTP id 3f1490d57ef6-e3812304661mr186116276.3.1731550895848; Wed, 13 Nov 2024 18:21:35 -0800 (PST) Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com. [209.85.219.177]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e3815478758sm46190276.59.2024.11.13.18.21.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Nov 2024 18:21:35 -0800 (PST) Received: by mail-yb1-f177.google.com with SMTP id 3f1490d57ef6-e30cf3ef571so17225276.3; Wed, 13 Nov 2024 18:21:35 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVQaNlSgczYuMcijMLI916YNEJrWO/NVw7KKKm6ymEkbm1tNYXPjfaIczIKGXGsu+8agGZnMhI2Y6v8cqh+8JDFm6Cz@freebsd.org, AJvYcCXGkQyBrXThgJp8//hS6Q6U0VvRGL/DlDfU5g2dN3zjw0VRpo9J6EM6b+YazPeHZ2X1CurOM2ZHOGYxKZoMQUgRun+G0DQ=@freebsd.org X-Received: by 2002:a05:6902:160d:b0:e2b:de2b:e467 with SMTP id 3f1490d57ef6-e337f8dfe89mr8536633276.9.1731550895309; Wed, 13 Nov 2024 18:21:35 -0800 (PST) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 References: <202411091725.4A9HPCHC015836@gitrepo.freebsd.org> In-Reply-To: <202411091725.4A9HPCHC015836@gitrepo.freebsd.org> Reply-To: jlduran@freebsd.org From: Jose Luis Duran Date: Wed, 13 Nov 2024 23:21:24 -0300 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: git: 62e6ca0f07e4 - main - ps(1): clean up after swapout removal To: Konstantin Belousov Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.82 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.92)[-0.917]; FORGED_SENDER(0.30)[jlduran@freebsd.org,jlduran@gmail.com]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17:c]; DMARC_POLICY_SOFTFAIL(0.10)[freebsd.org : SPF not aligned (relaxed), No valid DKIM,none]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_THREE(0.00)[3]; RCVD_TLS_LAST(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FROM_HAS_DN(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[209.85.219.180:from,209.85.219.177:received]; MLMMJ_DEST(0.00)[dev-commits-src-all@freebsd.org,dev-commits-src-main@freebsd.org]; REPLYTO_ADDR_EQ_FROM(0.00)[]; FROM_NEQ_ENVFROM(0.00)[jlduran@freebsd.org,jlduran@gmail.com]; MISSING_XM_UA(0.00)[]; R_DKIM_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.219.180:from]; FREEFALL_USER(0.00)[jlduran]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; HAS_REPLYTO(0.00)[jlduran@freebsd.org] X-Rspamd-Queue-Id: 4XpkRj13Phz48L4 X-Spamd-Bar: -- On Sat, Nov 9, 2024 at 2:25=E2=80=AFPM Konstantin Belousov wrote: > > The branch main has been updated by kib: > > URL: https://cgit.FreeBSD.org/src/commit/?id=3D62e6ca0f07e448da27cb2cc816= 5e749e7fdfcd7e > > commit 62e6ca0f07e448da27cb2cc8165e749e7fdfcd7e > Author: Konstantin Belousov > AuthorDate: 2024-11-09 01:37:07 +0000 > Commit: Konstantin Belousov > CommitDate: 2024-11-09 17:22:42 +0000 > > ps(1): clean up after swapout removal > > The process flag P_INMEM is always set. Eliminate all checks for the > bit. Also eliminate LAZY_PS define and code covered by it: we do no= t > have an u-area for long time, and it cannot be swapped out. > > Also eliminate setting controlled by the '-f' switch, but accept it f= or > backward compatibility. > > The 'W' process secondary state (swapped out) is impossible, stop > calculating it. > > Reviewed by: markj > Sponsored by: The FreeBSD Foundation > Differential revision: https://reviews.freebsd.org/D47492 > --- > bin/ps/Makefile | 7 ------- > bin/ps/print.c | 6 +----- > bin/ps/ps.1 | 9 +-------- > bin/ps/ps.c | 41 ++++++++--------------------------------- > 4 files changed, 10 insertions(+), 53 deletions(-) > > diff --git a/bin/ps/Makefile b/bin/ps/Makefile > index a25b6a796ed0..71973b34dd24 100644 > --- a/bin/ps/Makefile > +++ b/bin/ps/Makefile > @@ -2,13 +2,6 @@ PACKAGE=3Druntime > PROG=3D ps > SRCS=3D fmt.c keyword.c nlist.c print.c ps.c > > -# > -# To support "lazy" ps for non root/wheel users > -# add -DLAZY_PS to the cflags. This helps > -# keep ps from being an unnecessary load > -# on large systems. > -# > -CFLAGS+=3D-DLAZY_PS > LIBADD=3D m kvm jail xo > > .include > diff --git a/bin/ps/print.c b/bin/ps/print.c > index a3423d8b3956..59631fb66a10 100644 > --- a/bin/ps/print.c > +++ b/bin/ps/print.c > @@ -253,8 +253,6 @@ state(KINFO *k, VARENT *ve __unused) > *cp =3D '?'; > } > cp++; > - if (!(flag & P_INMEM)) > - *cp++ =3D 'W'; > if (k->ki_p->ki_nice < NZERO || k->ki_p->ki_pri.pri_class =3D=3D = PRI_REALTIME) > *cp++ =3D '<'; > else if (k->ki_p->ki_nice > NZERO || k->ki_p->ki_pri.pri_class = =3D=3D PRI_IDLE) > @@ -633,7 +631,7 @@ getpcpu(const KINFO *k) > #define fxtofl(fixpt) ((double)(fixpt) / fscale) > > /* XXX - I don't like this */ > - if (k->ki_p->ki_swtime =3D=3D 0 || (k->ki_p->ki_flag & P_INMEM) = =3D=3D 0) > + if (k->ki_p->ki_swtime =3D=3D 0) > return (0.0); > if (rawcpu) > return (100.0 * fxtofl(k->ki_p->ki_pctcpu)); > @@ -661,8 +659,6 @@ getpmem(KINFO *k) > if (failure) > return (0.0); > > - if ((k->ki_p->ki_flag & P_INMEM) =3D=3D 0) > - return (0.0); > /* XXX want pmap ptpages, segtab, etc. (per architecture) */ > /* XXX don't have info about shared */ > fracmem =3D ((double)k->ki_p->ki_rssize) / mempages; > diff --git a/bin/ps/ps.1 b/bin/ps/ps.1 > index 828239fd2ba9..8ece5b1bbfad 100644 > --- a/bin/ps/ps.1 > +++ b/bin/ps/ps.1 > @@ -159,9 +159,6 @@ does not imply > but works well with it. > .It Fl e > Display the environment as well. > -.It Fl f > -Show command-line and environment information about swapped out processe= s. > -This option is honored only if the UID of the user is 0. > .It Fl G > Display information about processes which are running with the specified > real group IDs. > @@ -358,9 +355,7 @@ the include file > .It Dv "P_TOTAL_STOP" Ta No "0x02000000" Ta "Stopped for system suspend" > .It Dv "P_INEXEC" Ta No "0x04000000" Ta Process is in Xr execve 2 > .It Dv "P_STATCHILD" Ta No "0x08000000" Ta "Child process stopped or exi= ted" > -.It Dv "P_INMEM" Ta No "0x10000000" Ta "Loaded into memory" > -.It Dv "P_SWAPPINGOUT" Ta No "0x20000000" Ta "Process is being swapped o= ut" > -.It Dv "P_SWAPPINGIN" Ta No "0x40000000" Ta "Process is being swapped in= " > +.It Dv "P_INMEM" Ta No "0x10000000" Ta "Always set, unused" > .It Dv "P_PPTRACE" Ta No "0x80000000" Ta "Vforked child issued ptrace(PT= _TRACEME)" > .El > .It Cm flags2 > @@ -491,8 +486,6 @@ The process is a session leader. > The process' parent is suspended during a > .Xr vfork 2 , > waiting for the process to exec or exit. > -.It Li W > -The process is swapped out. > .It Li X > The process is being traced or debugged. > .El > diff --git a/bin/ps/ps.c b/bin/ps/ps.c > index b0af2bdf37ca..49c69bb76084 100644 > --- a/bin/ps/ps.c > +++ b/bin/ps/ps.c > @@ -68,14 +68,6 @@ > #define W_SEP " \t" /* "Whitespace" list separators *= / > #define T_SEP "," /* "Terminate-element" list separ= ators */ > > -#ifdef LAZY_PS > -#define DEF_UREAD 0 > -#define OPT_LAZY_f "f" > -#else > -#define DEF_UREAD 1 /* Always do the more-expensive r= ead. */ > -#define OPT_LAZY_f /* I.e., the `-f' option is not a= dded. */ > -#endif > - > /* > * isdigit takes an `int', but expects values in the range of unsigned c= har. > * This wrapper ensures that values from a 'char' end up in the correct = range. > @@ -92,7 +84,6 @@ int showthreads; /* will threads be shown?= */ > > struct velisthead varlist =3D STAILQ_HEAD_INITIALIZER(varlist); > > -static int forceuread =3D DEF_UREAD; /* Do extra work to get u-area= . */ > static kvm_t *kd; > static int needcomm; /* -o "command" */ > static int needenv; /* -e */ > @@ -154,7 +145,7 @@ static char vfmt[] =3D "pid,state,time,sl,re,pagein,v= sz,rss,lim,tsiz," > "%cpu,%mem,command"; > static char Zfmt[] =3D "label"; > > -#define PS_ARGS "AaCcD:de" OPT_LAZY_f "G:gHhjJ:LlM:mN:O:o:p:rSTt:= U:uvwXxZ" > +#define PS_ARGS "AaCcD:defG:gHhjJ:LlM:mN:O:o:p:rSTt:U:uvwXxZ" > > int > main(int argc, char *argv[]) > @@ -272,12 +263,9 @@ main(int argc, char *argv[]) > case 'e': /* XXX set ufmt */ > needenv =3D 1; > break; > -#ifdef LAZY_PS > case 'f': > - if (getuid() =3D=3D 0 || getgid() =3D=3D 0) > - forceuread =3D 1; > + /* compat */ > break; > -#endif > case 'G': > add_list(&gidlist, optarg); > xkeep_implied =3D 1; > @@ -1276,31 +1264,21 @@ fmt(char **(*fn)(kvm_t *, const struct kinfo_proc= *, int), KINFO *ki, > return (s); > } > > -#define UREADOK(ki) (forceuread || (ki->ki_p->ki_flag & P_INMEM)) > - > static void > saveuser(KINFO *ki) > { > char tdname[COMMLEN + 1]; > char *argsp; > > - if (ki->ki_p->ki_flag & P_INMEM) { > - /* > - * The u-area might be swapped out, and we can't get > - * at it because we have a crashdump and no swap. > - * If it's here fill in these fields, otherwise, just > - * leave them 0. > - */ > - ki->ki_valid =3D 1; > - } else > - ki->ki_valid =3D 0; > + ki->ki_valid =3D 1; > + > /* > * save arguments if needed > */ > if (needcomm) { > if (ki->ki_p->ki_stat =3D=3D SZOMB) { > ki->ki_args =3D strdup(""); > - } else if (UREADOK(ki) || (ki->ki_p->ki_args !=3D NULL)) = { Apparently this is missing an explicit check of ki->ki_p->ki_flag, causing the processes in square brackets be printed within parentheses, that is, taking the else path below, and making test: https://ci.freebsd.org/view/Test/job/FreeBSD-main-amd64-test/lastCompletedB= uild/testReport/bin.pkill/pgrep-_s_test/main/ fail. I have already sent a message via Phabricator, but I am unsure if it has visibility there after the commit. I apologize if this is something that's already known. Thank you! > + } else if (ki->ki_p->ki_args !=3D NULL) { > (void)snprintf(tdname, sizeof(tdname), "%s%s", > ki->ki_p->ki_tdname, ki->ki_p->ki_moretdname)= ; > ki->ki_args =3D fmt(kvm_getargv, ki, > @@ -1315,11 +1293,8 @@ saveuser(KINFO *ki) > ki->ki_args =3D NULL; > } > if (needenv) { > - if (UREADOK(ki)) > - ki->ki_env =3D fmt(kvm_getenvv, ki, > - (char *)NULL, (char *)NULL, 0); > - else > - ki->ki_env =3D strdup("()"); > + ki->ki_env =3D fmt(kvm_getenvv, ki, (char *)NULL, > + (char *)NULL, 0); > if (ki->ki_env =3D=3D NULL) > xo_errx(1, "malloc failed"); > } else { > @@ -1479,7 +1454,7 @@ pidmax_init(void) > static void __dead2 > usage(void) > { > -#define SINGLE_OPTS "[-aCcde" OPT_LAZY_f "HhjlmrSTuvwXxZ]" > +#define SINGLE_OPTS "[-aCcdeHhjlmrSTuvwXxZ]" > > xo_error("%s\n%s\n%s\n%s\n%s\n", > "usage: ps [--libxo] " SINGLE_OPTS " [-O fmt | -o fmt]", --=20 Jose Luis Duran