HardenedBSD Services pushed to branch freebsd/current/main at HardenedBSD / HardenedBSD
Commits:
350f3197 by Igor Ostapenko at 2025-12-26T20:06:56+00:00
kyua: Make "debug -p" skip writing stdout/stderr to tmp files
Reviewed by: kp, ngie
Differential Revision:
https://reviews.freebsd.org/D54363
- - - - -
939ac0c8 by Doug Moore at 2025-12-26T16:07:34-06:00
vnode_pager: clean up undirty_pages()
The first (second) loop of vnode_pager_undirty_pages() includes an
if-test to test whether an iteration is the last (first). Move those
if-tests out of their loops. That allows the compiler to unroll the
loops.
Reviewed by: alc, kib
Differential Revision:
https://reviews.freebsd.org/D54353
- - - - -
086bedb1 by Dimitry Andric at 2025-12-27T00:11:17+01:00
tools.build: also add sys/_visible.h to SYSINCS
This is needed since sys/cdefs.h includes sys/_visible.h.
Reported by: kib
Fixes: 1c9ff80f0635
MFC after: 3 days
- - - - -
5 changed files:
- contrib/kyua/cli/cmd_debug.cpp
- contrib/kyua/engine/scheduler.cpp
- contrib/kyua/engine/scheduler.hpp
- sys/vm/vnode_pager.c
- tools/build/Makefile
Changes:
=====================================
contrib/kyua/cli/cmd_debug.cpp
=====================================
@@ -149,7 +149,11 @@ cmd_debug::run(cmdline::ui* ui, const cmdline::parsed_cmdline& cmdline,
const engine::test_filter filter = engine::test_filter::parse(
test_case_name);
- auto debugger = std::shared_ptr< engine::debugger >(new dbg(ui, cmdline));
+ engine::debugger_ptr debugger = nullptr;
+ if (cmdline.has_option(pause_before_cleanup_upon_fail_option.long_name())
+ || cmdline.has_option(pause_before_cleanup_option.long_name())) {
+ debugger = std::shared_ptr< engine::debugger >(new dbg(ui, cmdline));
+ }
const drivers::debug_test::result result = drivers::debug_test::drive(
debugger,
=====================================
contrib/kyua/engine/scheduler.cpp
=====================================
@@ -1283,7 +1283,9 @@ scheduler::exec_handle
scheduler::scheduler_handle::spawn_test(
const model::test_program_ptr test_program,
const std::string& test_case_name,
- const config::tree& user_config)
+ const config::tree& user_config,
+ const utils::optional<utils::fs::path>& stdout_target,
+ const utils::optional<utils::fs::path>& stderr_target)
{
_pimpl->generic.check_interrupt();
@@ -1305,7 +1307,7 @@ scheduler::scheduler_handle::spawn_test(
run_test_program(interface, test_program, test_case_name,
user_config),
test_case.get_metadata().timeout(),
- unprivileged_user);
+ unprivileged_user, stdout_target, stderr_target);
const exec_data_ptr data(new test_exec_data(
test_program, test_case_name, interface, user_config, handle.pid()));
@@ -1563,8 +1565,16 @@ scheduler::scheduler_handle::debug_test(
const fs::path& stdout_target,
const fs::path& stderr_target)
{
+ optional<fs::path> out = none;
+ optional<fs::path> err = none;
+ const model::test_case& test_case = test_program->find(test_case_name);
+ if (test_case.get_debugger() != nullptr) {
+ out = stdout_target;
+ err = stderr_target;
+ }
+
const exec_handle exec_handle = spawn_test(
- test_program, test_case_name, user_config);
+ test_program, test_case_name, user_config, out, err);
result_handle_ptr result_handle = wait_any();
// TODO(jmmv): We need to do this while the subprocess is alive. This is
@@ -1574,12 +1584,12 @@ scheduler::scheduler_handle::debug_test(
// Unfortunately, we cannot do so. We cannot just read and block from a
// file, waiting for further output to appear... as this only works on pipes
// or sockets. We need a better interface for this whole thing.
- {
+ if (test_case.get_debugger() == nullptr) {
std::unique_ptr< std::ostream > output = utils::open_ostream(
stdout_target);
*output << utils::read_file(result_handle->stdout_file());
}
- {
+ if (test_case.get_debugger() == nullptr) {
std::unique_ptr< std::ostream > output = utils::open_ostream(
stderr_target);
*output << utils::read_file(result_handle->stderr_file());
=====================================
contrib/kyua/engine/scheduler.hpp
=====================================
@@ -74,6 +74,8 @@
#include "utils/process/executor_fwd.hpp"
#include "utils/process/status_fwd.hpp"
+using utils::none;
+
namespace engine {
namespace scheduler {
@@ -248,7 +250,9 @@ class scheduler_handle {
const utils::config::tree&);
exec_handle spawn_test(const model::test_program_ptr,
const std::string&,
- const utils::config::tree&);
+ const utils::config::tree&,
+ const utils::optional<utils::fs::path>& = none,
+ const utils::optional<utils::fs::path>& = none);
result_handle_ptr wait_any(void);
result_handle_ptr debug_test(const model::test_program_ptr,
=====================================
sys/vm/vnode_pager.c
=====================================
@@ -1523,49 +1523,47 @@ void
vnode_pager_undirty_pages(vm_page_t *ma, int *rtvals, int written, off_t eof,
int lpos)
{
- int i, pos, pos_devb;
+ int i, npages, pos;
- if (written == 0 && eof >= lpos)
- return;
- for (i = 0, pos = 0; pos < written; i++, pos += PAGE_SIZE) {
- if (pos < trunc_page(written)) {
- rtvals[i] = VM_PAGER_OK;
- vm_page_undirty(ma[i]);
- } else {
- /* Partially written page. */
- rtvals[i] = VM_PAGER_AGAIN;
- vm_page_clear_dirty(ma[i], 0, written & PAGE_MASK);
- }
+ /* Process pages up to round_page(written) */
+ pos = written & PAGE_MASK;
+ npages = atop(written);
+ for (i = 0; i < npages; i++) {
+ rtvals[i] = VM_PAGER_OK;
+ vm_page_undirty(ma[i]);
+ }
+ if (pos != 0) {
+ /* Partially written page. */
+ rtvals[i] = VM_PAGER_AGAIN;
+ vm_page_clear_dirty(ma[i], 0, pos);
}
- if (eof >= lpos) /* avoid truncation */
- return;
- for (pos = eof, i = OFF_TO_IDX(trunc_page(pos)); pos < lpos; i++) {
- if (pos != trunc_page(pos)) {
- /*
- * The page contains the last valid byte in
- * the vnode, mark the rest of the page as
- * clean, potentially making the whole page
- * clean.
- */
- pos_devb = roundup2(pos & PAGE_MASK, DEV_BSIZE);
- vm_page_clear_dirty(ma[i], pos_devb, PAGE_SIZE -
- pos_devb);
- /*
- * If the page was cleaned, report the pageout
- * on it as successful. msync() no longer
- * needs to write out the page, endlessly
- * creating write requests and dirty buffers.
- */
- if (ma[i]->dirty == 0)
- rtvals[i] = VM_PAGER_OK;
+ /* Process pages from trunc_page(eof) to round_page(lpos) */
+ pos = eof & PAGE_MASK;
+ i = atop(eof);
+ npages = atop(lpos);
+ if (i < npages && pos != 0) {
+ /*
+ * The page contains the last valid byte in the
+ * vnode, mark the rest of the page as clean,
+ * potentially making the whole page clean.
+ */
+ pos = roundup2(pos, DEV_BSIZE);
+ vm_page_clear_dirty(ma[i], pos, PAGE_SIZE - pos);
- pos = round_page(pos);
- } else {
- /* vm_pageout_flush() clears dirty */
- rtvals[i] = VM_PAGER_BAD;
- pos += PAGE_SIZE;
- }
+ /*
+ * If the page was cleaned, report the pageout on it
+ * as successful. msync() no longer needs to write
+ * out the page, endlessly creating write requests
+ * and dirty buffers.
+ */
+ if (ma[i]->dirty == 0)
+ rtvals[i] = VM_PAGER_OK;
+ i++;
+ }
+ for (; i < npages; i++) {
+ /* vm_pageout_flush() clears dirty */
+ rtvals[i] = VM_PAGER_BAD;
}
}
=====================================
tools/build/Makefile
=====================================
@@ -353,6 +353,7 @@ DISKINCS+= ${SRCTOP}/sys/sys/disk/bsd.h
# Needed to build most of the things below, which include sys/cdefs.h either
# directly or transitively
+SYSINCS+= ${SRCTOP}/sys/sys/_visible.h
SYSINCS+= ${SRCTOP}/sys/sys/cdefs.h
# Needed to build config (since it uses libnv)
View it on GitLab:
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD/-/compare/0d31189cbce4de142a43b65037beb7bf8c09cf26...086bedb11a853801e82234b8a1a64f0df52d9e52
--
View it on GitLab:
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD/-/compare/0d31189cbce4de142a43b65037beb7bf8c09cf26...086bedb11a853801e82234b8a1a64f0df52d9e52
You're receiving this email because of your account on
git.hardenedbsd.org.