From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 41F1C45BD8; Fri, 25 Oct 2024 22:26:43 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 474A9402D3; Fri, 25 Oct 2024 22:26:40 +0200 (CEST) Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) by mails.dpdk.org (Postfix) with ESMTP id 77DDA4029A for ; Fri, 25 Oct 2024 22:26:38 +0200 (CEST) Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2fb6110c8faso23894821fa.1 for ; Fri, 25 Oct 2024 13:26:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729887997; x=1730492797; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hcf++frLvvhC1S5qwGfhE6iF70k+pofzTi0gKxHieyQ=; b=IFb+U4PCaYDbcDg18nHt8gUIGScmKYYqtviJZ+fIPMhoHwu7Qqqsb1Rew1CtiBo/tT saDY3ezdNAu8ni7cgoMqO2dYvc/R4Eagsj+Su3dCjKAbyBv0ZRNIZSURxikIb8OoMZ6f aH7Q1o3sVtrcmaGpo+1ZAqENMFkHnNocGwciHGpTQL23WNh5QM5zrlimuVuQ3MdQve7f QpLSdkYzQAg2guVNhtprNnbgMKosPXURh/LoxiQsHylzfu1L1HUhhVISsjd5EduieL5O aCR7VEhkc01qvdhfn0ckq78iWqHgEWX9BvNdJXIYlq8mUILTw1cMSmEyrvv6/e2i7o5b rQtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729887997; x=1730492797; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hcf++frLvvhC1S5qwGfhE6iF70k+pofzTi0gKxHieyQ=; b=QMndeaQ3gGc5URh5NnYsF2uYPyCsAW+wHU66vgmVAHSY6kINPfLBho3kXZS2tuYW5f OwenV8H0kE563n9I54uuzryfBJiOLG9iNVZyxCmdkeNcDl/zG67E8dbUe5GfxHzEw+Ap AgvFBBVkywtTXquHcW2pSTOOPPoL//8EF1kcNKUASpePe0hX4ojmJiEq/1/XNIN8gcrp CkLkZsid+8N81jPkVF0TmF2BqcTd3ZpZBSOIoTXMSTDecK/zytAyXz6vXM3s39dlQgAe IFreoqMsLiShNHqEvxoZA7XpJ5oAia76BX5b4pI+WYLyvU7kypjA8ei5yULrA0f9W8Iy WuQw== X-Gm-Message-State: AOJu0YwhIE872QQhMYmLj8Z9LVt1zf1gNttEA15F5/eyjquruCfdUFUc 4V90LxcnfieRybv2vD/m7xn9gs5/ZK7vA3xUMebKaqPoLkf9ncyyKzcf4C8s X-Google-Smtp-Source: AGHT+IFUKMDgB1l+zrIChAeCb+MjiMZnVfAqeFxpTLhiLYKQXtxJ/zkUVYECs8oiCuA/qlPAkkqjzw== X-Received: by 2002:a2e:130a:0:b0:2fb:5cff:fcd8 with SMTP id 38308e7fff4ca-2fcbe04f0c7mr2477131fa.34.1729887996814; Fri, 25 Oct 2024 13:26:36 -0700 (PDT) Received: from sovereign.. (broadband-109-173-43-194.ip.moscow.rt.ru. [109.173.43.194]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2fcb453e341sm3101941fa.55.2024.10.25.13.26.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 13:26:35 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Anatoly Burakov , Lewis Donzis , Dmitry Kozlyuk Subject: [PATCH v2 1/2] contigmem: support including mapped buffers in core dump Date: Fri, 25 Oct 2024 23:26:14 +0300 Message-Id: <20241025202615.2581513-2-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.38.4 In-Reply-To: <20241025202615.2581513-1-dmitry.kozliuk@gmail.com> References: <20241023231859.1323727-1-kozlyuk@bifit.com> <20241025202615.2581513-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org It was impossible to include mapped contigmem buffers in core dump. Add hw.contigmem.coredump_enable tunable to control the inclusion. Mappings backed by OBJ_FICTITIOUS are excluded from core dump. While contigmem is a device and its OBJT_DEVICE mappings get this flag, they are actually backed by memory. Clear OBJ_FICTITIOUS mapping bit to include them in core dump. Do this only if hw.contigmem.coredump_enable=1. Signed-off-by: Dmitry Kozlyuk --- doc/guides/freebsd_gsg/build_dpdk.rst | 27 ++++++++++++++++++++------- kernel/freebsd/contigmem/contigmem.c | 8 ++++++++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/doc/guides/freebsd_gsg/build_dpdk.rst b/doc/guides/freebsd_gsg/build_dpdk.rst index 86e8e5a805..387ec52820 100644 --- a/doc/guides/freebsd_gsg/build_dpdk.rst +++ b/doc/guides/freebsd_gsg/build_dpdk.rst @@ -86,6 +86,22 @@ module loading using:: kenv hw.contigmem.num_buffers=n kenv hw.contigmem.buffer_size=m +Where n is the number of blocks and m is the size in bytes of each area of +contiguous memory. A default of two buffers of size 1073741824 bytes (1 Gigabyte) +each is set during module load if they are not specified in the environment. + +Buffers are excluded from core dump by default. +Mapped buffers can be included in core dump using the following tunable: + + hw.contigmem.coredump_enable=1 + +.. note:: + + Including contigmem buffers in core dump file increases its size, + which may fill the storage or overload the transport. + Buffers typically hold data processed by the application, + like network packets, which may contain sensitive information. + The kernel environment variables can also be specified during boot by placing the following in ``/boot/loader.conf``: @@ -93,15 +109,12 @@ following in ``/boot/loader.conf``: hw.contigmem.num_buffers=n hw.contigmem.buffer_size=m + hw.contigmem.coredump_enable=1 The variables can be inspected using the following command:: sysctl -a hw.contigmem -Where n is the number of blocks and m is the size in bytes of each area of -contiguous memory. A default of two buffers of size 1073741824 bytes (1 Gigabyte) -each is set during module load if they are not specified in the environment. - The module can then be loaded using kldload:: kldload contigmem @@ -115,13 +128,13 @@ up time. This can be achieved by placing lines similar to the following into hw.contigmem.num_buffers=1 hw.contigmem.buffer_size=1073741824 + hw.contigmem.coredump_enable=1 contigmem_load="YES" .. note:: - The contigmem_load directive should be placed after any definitions of - ``hw.contigmem.num_buffers`` and ``hw.contigmem.buffer_size`` if the default values - are not to be used. + The ``contigmem_load`` directive should be placed after any definitions + of ``hw.contigmem.*`` if the default values are not to be used. An error such as:: diff --git a/kernel/freebsd/contigmem/contigmem.c b/kernel/freebsd/contigmem/contigmem.c index 7dd87599d9..591e46dded 100644 --- a/kernel/freebsd/contigmem/contigmem.c +++ b/kernel/freebsd/contigmem/contigmem.c @@ -51,6 +51,7 @@ static d_close_t contigmem_close; static int contigmem_num_buffers = RTE_CONTIGMEM_DEFAULT_NUM_BUFS; static int64_t contigmem_buffer_size = RTE_CONTIGMEM_DEFAULT_BUF_SIZE; +static bool contigmem_coredump_enable; static eventhandler_tag contigmem_eh_tag; static struct contigmem_buffer contigmem_buffers[RTE_CONTIGMEM_MAX_NUM_BUFS]; @@ -59,6 +60,7 @@ static int contigmem_refcnt; TUNABLE_INT("hw.contigmem.num_buffers", &contigmem_num_buffers); TUNABLE_QUAD("hw.contigmem.buffer_size", &contigmem_buffer_size); +TUNABLE_BOOL("hw.contigmem.coredump_enable", &contigmem_coredump_enable); static SYSCTL_NODE(_hw, OID_AUTO, contigmem, CTLFLAG_RD, 0, "contigmem"); @@ -68,6 +70,8 @@ SYSCTL_QUAD(_hw_contigmem, OID_AUTO, buffer_size, CTLFLAG_RD, &contigmem_buffer_size, 0, "Size of each contiguous buffer"); SYSCTL_INT(_hw_contigmem, OID_AUTO, num_references, CTLFLAG_RD, &contigmem_refcnt, 0, "Number of references to contigmem"); +SYSCTL_BOOL(_hw_contigmem, OID_AUTO, coredump_enable, CTLFLAG_RD, + &contigmem_coredump_enable, 0, "Include mapped buffers in core dump"); static SYSCTL_NODE(_hw_contigmem, OID_AUTO, physaddr, CTLFLAG_RD, 0, "physaddr"); @@ -357,5 +361,9 @@ contigmem_mmap_single(struct cdev *cdev, vm_ooffset_t *offset, vm_size_t size, *obj = cdev_pager_allocate(vmh, OBJT_DEVICE, &contigmem_cdev_pager_ops, size, nprot, *offset, curthread->td_ucred); + /* Mappings backed by OBJ_FICTITIOUS are excluded from core dump. */ + if (contigmem_coredump_enable) + (*obj)->flags &= ~OBJ_FICTITIOUS; + return 0; } -- 2.38.4