From nobody Sun Aug 18 09:35:11 2024 X-Original-To: freebsd-hackers@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 4WmrDn6kF5z5SmCP for ; Sun, 18 Aug 2024 09:35:21 +0000 (UTC) (envelope-from yuri@aetern.org) Received: from fhigh8-smtp.messagingengine.com (fhigh8-smtp.messagingengine.com [103.168.172.159]) (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 mx1.freebsd.org (Postfix) with ESMTPS id 4WmrDn3DS4z4DZ5 for ; Sun, 18 Aug 2024 09:35:21 +0000 (UTC) (envelope-from yuri@aetern.org) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=aetern.org header.s=fm3 header.b=mIWcOrA7; dkim=pass header.d=messagingengine.com header.s=fm3 header.b="B qmSKfO"; spf=pass (mx1.freebsd.org: domain of yuri@aetern.org designates 103.168.172.159 as permitted sender) smtp.mailfrom=yuri@aetern.org Received: from phl-compute-06.internal (phl-compute-06.nyi.internal [10.202.2.46]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 77E231151B92 for ; Sun, 18 Aug 2024 05:35:17 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Sun, 18 Aug 2024 05:35:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aetern.org; h=cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1723973717; x=1724060117; bh=HWL0uQyElZbe33EsPwnXjksBrB1hEty8stMIVDt5ZfY=; b= mIWcOrA75ReQerQR4RQWQ+sCDqCjRL2kE5dJn2Wo6T8LJw156WHSFd+tw+lPnPMI nP+ZQhXLqEzynpBWNW7ZivpUttRHVznPovJehD67o5Y9jX3RbcLEcnUq1N1HLymq rqUGW1TwgWHWVSw5ZO2HTBFIUln5Llh8tDF3datpvzD4A0Qle78Gag9RduIm3GU6 A/S4ZGxGCHam7krA9738FQfYX2D/Bw+LS2Z4jy+T1plD0i76YOAcw1YSxu+02be1 +Zu3q0zAOU2IgSABJZDBEcjS27mwUofDibLXM2akUzxOtzIZKsYihNxkP4kftPLw H2ldBbdWB7hEydz53b14pg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1723973717; x= 1724060117; bh=HWL0uQyElZbe33EsPwnXjksBrB1hEty8stMIVDt5ZfY=; b=B qmSKfOrR/TaIc/Tdds6abdpUYfRDCSfkr2h4AGj1pqDsW43OcZJzOXu3XbbU9xGo TRmomRluhowPGFyTuYvLx2WMuKTD/L042tap7aoguZjNgSiYRZqTjG29DsLRM3Xf k7RnObTErg+Ju78fs6kjYtEGCq/0a/UgD7gh77rSfbB+G4yBZ4Jnu1alvussqKAW 4iFCGxg2asBln7vyrWWJcpyZ+Of1vyhIYqChjxtoH6V4BufXccEehdRB2fEvbB39 eJpOPLqCrOHN17BiKzA5xSneaFtFLHmkvOhi8uVscEHd63+qgyZP1Sn9lcNnRg5c Jm1HWSjIbmB4y0eSFje/g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudduvddgudekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefkffggfg fuvfhfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpegjuhhrihcurfgrnhhkohhvuceo hihurhhisegrvghtvghrnhdrohhrgheqnecuggftrfgrthhtvghrnhepjedtkeejveehke evgfeiledtheeuudeufefgueetuefhheduledtuedvgeeiudelnecuffhomhgrihhnpehs figrphdrfhhrvggvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhephihurhhisegrvghtvghrnhdrohhrghdpnhgspghrtghpthhtohepuddpmhho uggvpehsmhhtphhouhhtpdhrtghpthhtohepfhhrvggvsghsugdqhhgrtghkvghrshesfh hrvggvsghsugdrohhrgh X-ME-Proxy: Feedback-ID: i0d79475b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sun, 18 Aug 2024 05:35:16 -0400 (EDT) Message-ID: Date: Sun, 18 Aug 2024 16:35:11 +0700 List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Can free swap size be determined from the sysctl information ? To: freebsd-hackers@freebsd.org References: <6076fe34-eb23-47cc-8bd2-6000ddf0a091@FreeBSD.org> Content-Language: en-US From: Yuri Pankov In-Reply-To: <6076fe34-eb23-47cc-8bd2-6000ddf0a091@FreeBSD.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spamd-Bar: / X-Rspamd-Pre-Result: action=no action; module=multimap; Matched map: local_wl_from X-Spamd-Result: default: False [0.61 / 15.00]; SUBJECT_ENDS_QUESTION(1.00)[]; R_SPF_ALLOW(-0.20)[+ip4:103.168.172.128/27]; R_DKIM_ALLOW(-0.20)[aetern.org:s=fm3,messagingengine.com:s=fm3]; XM_UA_NO_VERSION(0.01)[]; FREEFALL_USER(0.00)[yuri]; ASN(0.00)[asn:209242, ipnet:103.168.172.0/24, country:US]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; MLMMJ_DEST(0.00)[freebsd-hackers@freebsd.org]; local_wl_from(0.00)[yuri@aetern.org]; DKIM_TRACE(0.00)[aetern.org:+,messagingengine.com:+] X-Rspamd-Queue-Id: 4WmrDn3DS4z4DZ5 Yuri wrote: > It seems that it should be possible to find free swap size from the > sysctl information, but it isn't obvious how to do this. > > > Here are all *swap* entries in the sysctl information: > $ sysctl -a | grep swap > 0 MD md98 68719441408 512 u 98 s 512 f 0 fs 0 l 68719441408 t vnode > file /disk-large1/swap-64GB label   > z0xfffff8004d862400 [shape=box,label="SWAP\nswap\nr#2"]; >      swap >            /disk-large1/swap-64GB > vm.swap_enabled: 1 > vm.domain.0.stats.unswappable: 0 > vm.swap_idle_threshold2: 10 > vm.swap_idle_threshold1: 2 > vm.swap_idle_enabled: 0 > vm.disable_swapspace_pageouts: 0 > vm.stats.vm.v_swappgsout: 433264 > vm.stats.vm.v_swappgsin: 94457 > vm.stats.vm.v_swapout: 65078 > vm.stats.vm.v_swapin: 11121 > vm.stats.swap.free_completed: 65205 > vm.stats.swap.free_deferred: 86103 > vm.nswapdev: 1 > vm.swap_fragmentation:   > vm.swap_async_max: 4 > vm.swap_maxpages: 48890752 > vm.swap_total: 68719439872 > vm.swap_reserved: 16267402461184 > > > top(1) shows 775M of free swap out of 64G total. > top(1) gets swap information from kvm_getswapinfo(3). And kvm_getswapinfo_sysctl() in lib/libkvm/kvm_getswapinfo.c has all the calculations used, someone (tm) just needs to translate it to Go. > Motivation: one Golang-based port needs free swap size information, and > I am trying to figure out how to get this information in Golang. > > Golang has the "sysctl" module.