From nobody Thu May 12 22:56:25 2022 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 2DAC71AE4658; Thu, 12 May 2022 22:56:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KznFj73Zpz3GRr; Thu, 12 May 2022 22:56:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652396186; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=eWXTdku/9h5ih/MHetTojGl3CogXWk67ON2GDW4Qgao=; b=m1JNrEp64AbCQSuduEBp8gV+AJpwYTreCncSYP7IzmiFdyBHcFeH1Atg/aaWiOyn3K8WJM MJFrKqjo3/PhUo3ldFcJMx94pT3SBC/fhEJulT5FQJK761vl5esD8CrtF9F0LduHCtqmpL 508B+nZGUIm9XzQsfY4QUIzcrb3PnHGxsas+FqKV3AWOpquIWRH/x5GBjqi60wYomiiFRY 9IeQdDlcPdGkjD25nXTofmhLfd2AHMl/S9fAR47LNXBCBi5fxqp5UhAPQ06lBCG5xoGaeV Tzh4k9jmj6MDBO36TSJYaaLxioemSrmwnspu7lzO7sSXYQl8CHerqeeO1A7r2g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9B0A517334; Thu, 12 May 2022 22:56:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 24CMuPxH020463; Thu, 12 May 2022 22:56:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24CMuP0V020462; Thu, 12 May 2022 22:56:25 GMT (envelope-from git) Date: Thu, 12 May 2022 22:56:25 GMT Message-Id: <202205122256.24CMuP0V020462@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: bc0c8c4d0cea - stable/13 - Clean up some of the core dumping code. 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: bc0c8c4d0cea689c2a098adf6fd7c3471a21e36e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652396186; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=eWXTdku/9h5ih/MHetTojGl3CogXWk67ON2GDW4Qgao=; b=sMchuy+DWf/RrHO1zTJrrUp6aMGxtHYIZOUrRsfiiRiOR4R7Agv3Fnxkw41+TSr28TT98h kA4iAZsR0mk6D/aWH1GhiD1qeRcJWn1tdbRvHG5DFgIBzq1fGp4o4I/LBeKqmLRX479bdF C5FON0t7j74OxQ28ERTEb6BA4fOE4p5qjCriqkywIJwynxv30ZuGAAVmNKds8wiCIjfPNk O2DQ+hdNomvfZljMIIJBZuQkznBSDHw/AOeXbqaWrNOwDnXjsoPwI6JLppRc4nwKRLAHvJ rYZNUlP6YjVeymzMuWh+iqknJZQ+RI8Zp/DEE5fE9HeZbESjcdWxXSPiEOsr7g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652396186; a=rsa-sha256; cv=none; b=gIA4LhPtLX2sHj+SBhjUtYu/LGAaNvLhVU5muaK9hr5VrFPRVwhWk/QaffbIJIwsY7/miq hWNrJ6iYzq8hJDfskZoTPY+9QELxNDWfvVQDpyQGAneJO6CoypD1CFjDPJeTW//MhKDSgW omQz7zNLz3cmbtcSdDPjo7QCPnY8KIHvB38y5K1NCHdmBHTwy4wzwN1uj5PIWB56zmsugp 1LUqsRDDuUCInxUVOpbjtcOVq8qCXslvwvvVKZBPqvJnVGMx9kiP5R5to2YINH/2BRFWcD XfUaGQAMxnTSAae1teiGdgaabztWkj6bQ8qfxFLkgSQEPNvw8SOVAEaGQNuK0g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=bc0c8c4d0cea689c2a098adf6fd7c3471a21e36e commit bc0c8c4d0cea689c2a098adf6fd7c3471a21e36e Author: Edward Tomasz Napierala AuthorDate: 2021-05-25 10:48:15 +0000 Commit: John Baldwin CommitDate: 2022-05-12 22:12:59 +0000 Clean up some of the core dumping code. No functional changes. Reviewed By: kib Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D30397 (cherry picked from commit 3b9971c8da7532462048062d589ef85cbb904f7e) --- sys/kern/kern_exec.c | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 5be0dee94197..656de54cabc2 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -1974,7 +1974,7 @@ exec_unregister(const struct execsw *execsw_arg) * Write out a core segment to the compression stream. */ static int -compress_chunk(struct coredump_params *p, char *base, char *buf, size_t len) +compress_chunk(struct coredump_params *cp, char *base, char *buf, size_t len) { size_t chunk_len; int error; @@ -1989,7 +1989,7 @@ compress_chunk(struct coredump_params *p, char *base, char *buf, size_t len) error = copyin(base, buf, chunk_len); if (error != 0) bzero(buf, chunk_len); - error = compressor_write(p->comp, buf, chunk_len); + error = compressor_write(cp->comp, buf, chunk_len); if (error != 0) break; base += chunk_len; @@ -1999,17 +1999,17 @@ compress_chunk(struct coredump_params *p, char *base, char *buf, size_t len) } int -core_write(struct coredump_params *p, const void *base, size_t len, +core_write(struct coredump_params *cp, const void *base, size_t len, off_t offset, enum uio_seg seg, size_t *resid) { - return (vn_rdwr_inchunks(UIO_WRITE, p->vp, __DECONST(void *, base), + return (vn_rdwr_inchunks(UIO_WRITE, cp->vp, __DECONST(void *, base), len, offset, seg, IO_UNIT | IO_DIRECT | IO_RANGELOCKED, - p->active_cred, p->file_cred, resid, p->td)); + cp->active_cred, cp->file_cred, resid, cp->td)); } int -core_output(char *base, size_t len, off_t offset, struct coredump_params *p, +core_output(char *base, size_t len, off_t offset, struct coredump_params *cp, void *tmpbuf) { vm_map_t map; @@ -2021,10 +2021,10 @@ core_output(char *base, size_t len, off_t offset, struct coredump_params *p, KASSERT((uintptr_t)base % PAGE_SIZE == 0, ("%s: user address %p is not page-aligned", __func__, base)); - if (p->comp != NULL) - return (compress_chunk(p, base, tmpbuf, len)); + if (cp->comp != NULL) + return (compress_chunk(cp, base, tmpbuf, len)); - map = &p->td->td_proc->p_vmspace->vm_map; + map = &cp->td->td_proc->p_vmspace->vm_map; for (; len > 0; base += runlen, offset += runlen, len -= runlen) { /* * Attempt to page in all virtual pages in the range. If a @@ -2044,7 +2044,7 @@ core_output(char *base, size_t len, off_t offset, struct coredump_params *p, } if (success) { - error = core_write(p, base, runlen, offset, + error = core_write(cp, base, runlen, offset, UIO_USERSPACE, &resid); if (error != 0) { if (error != EFAULT) @@ -2067,13 +2067,13 @@ core_output(char *base, size_t len, off_t offset, struct coredump_params *p, } } if (!success) { - error = vn_start_write(p->vp, &mp, V_WAIT); + error = vn_start_write(cp->vp, &mp, V_WAIT); if (error != 0) break; - vn_lock(p->vp, LK_EXCLUSIVE | LK_RETRY); - error = vn_truncate_locked(p->vp, offset + runlen, - false, p->td->td_ucred); - VOP_UNLOCK(p->vp); + vn_lock(cp->vp, LK_EXCLUSIVE | LK_RETRY); + error = vn_truncate_locked(cp->vp, offset + runlen, + false, cp->td->td_ucred); + VOP_UNLOCK(cp->vp); vn_finished_write(mp); if (error != 0) break; @@ -2088,10 +2088,12 @@ core_output(char *base, size_t len, off_t offset, struct coredump_params *p, int sbuf_drain_core_output(void *arg, const char *data, int len) { - struct coredump_params *p; + struct coredump_params *cp; + struct proc *p; int error, locked; - p = (struct coredump_params *)arg; + cp = arg; + p = cp->td->td_proc; /* * Some kern_proc out routines that print to this sbuf may @@ -2101,19 +2103,18 @@ sbuf_drain_core_output(void *arg, const char *data, int len) * can safely release the lock before draining and acquire * again after. */ - locked = PROC_LOCKED(p->td->td_proc); + locked = PROC_LOCKED(p); if (locked) - PROC_UNLOCK(p->td->td_proc); - if (p->comp != NULL) - error = compressor_write(p->comp, __DECONST(char *, data), len); + PROC_UNLOCK(p); + if (cp->comp != NULL) + error = compressor_write(cp->comp, __DECONST(char *, data), len); else - error = core_write(p, __DECONST(void *, data), len, p->offset, + error = core_write(cp, __DECONST(void *, data), len, cp->offset, UIO_SYSSPACE, NULL); if (locked) - PROC_LOCK(p->td->td_proc); + PROC_LOCK(p); if (error != 0) return (-error); - p->offset += len; + cp->offset += len; return (len); } -