From owner-freebsd-stable@freebsd.org Tue Sep 22 18:09:06 2020 Return-Path: Delivered-To: freebsd-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 363473F1B97 for ; Tue, 22 Sep 2020 18:09:06 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) (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 "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Bwq7h60f6z4PMH for ; Tue, 22 Sep 2020 18:09:04 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-io1-xd41.google.com with SMTP id m17so20702089ioo.1 for ; Tue, 22 Sep 2020 11:09:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=EIDIS1M+bYqdJSWugOC8B0n+ieHD3hAUN0RrFmotooI=; b=CwoD9s1k71OrzGhOrjYS3xcIkpuNdow3lTkWwHw/ZM2vOaRBXvkGa73CSYuF5kVRca Pa+6lWu4bTY4nZbLZcfBqJ3f5+6A+FQHGPVhBoAnzWLC23g7mo+R/IHdqlF4aqBj/KVw jYmdgfmlSSZa3RS++5TPNi5KmMw7ReZ8y5KIUxY4NHgmU4w1Kdg2bfDW5TZrX2v45mr/ jGNcomSL8wkfWG8wLDhH1/bilz4bg9z6HWV1ol6D+hhDVVHjOAxSqWeIPzmUa0ea2gtq y0kAcKMC/jMf9a5vyobZap5Cisnh5aMXA/plmHF/zthKlSF57UsiD1KeUqHgGf1aw3aF q1YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=EIDIS1M+bYqdJSWugOC8B0n+ieHD3hAUN0RrFmotooI=; b=VAkruSLN1b+YVt2aqyPtR7hScWJFOgzk+3BiZn3YcNcw6X+XjiaVhimr01YXPlAKJh kXMRhYHkNbolO0n1yaETN7AN2GmkqqQs5ywuBbFxkAvt4P3jA9FmwxVS3X88UzIK14M2 5Z6jZ0XYgE/tHlQPT8KsK5y/toZpdIXH7Yxhx7IyhnQCDAuIikeaLqU2lx0C/DzvH9Wr H+Vks1jR+ff6YLW5V0C0d+Sp3nq+FuuSSX3Im+R0HLlTRh1QEP9giPC9nvWp5TBKGNrE pJIO4UD53iM9AlfgWwItvCxGqUojMWFb7ga4Qt1iN4XYB6l4AtTfuHIqFJbAxHmuW6UN //6Q== X-Gm-Message-State: AOAM530974Hmn9YuQvMvmJ+kB1EStSgFwEcYVEOnTiCSRAdEODxeSjuS 2ucG0FZicw+sNrc544ZibxOeTB3mVvT3BQ== X-Google-Smtp-Source: ABdhPJxAOzftDBqMlWJ1GJ/iTuy29/bbIvXBQDniaNX0qlmLK1/QCCiDarr2BUKGL8hkUenzA86edg== X-Received: by 2002:a05:6638:4:: with SMTP id z4mr5025190jao.123.1600798143808; Tue, 22 Sep 2020 11:09:03 -0700 (PDT) Received: from raichu (toroon0560w-lp130-01-174-88-77-103.dsl.bell.ca. [174.88.77.103]) by smtp.gmail.com with ESMTPSA id m13sm8183429ilj.70.2020.09.22.11.09.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2020 11:09:03 -0700 (PDT) Sender: Mark Johnston Date: Tue, 22 Sep 2020 14:09:01 -0400 From: Mark Johnston To: Peter Cc: freebsd-stable@freebsd.org Subject: Re: How to free used Swap-Space? Message-ID: <20200922180901.GC70673@raichu> References: <20200922160801.GA19535@gate.oper.dinoex.org> <20200922163319.GA70673@raichu> <20200922173107.GA27670@gate.oper.dinoex.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200922173107.GA27670@gate.oper.dinoex.org> X-Rspamd-Queue-Id: 4Bwq7h60f6z4PMH X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=CwoD9s1k; dmarc=none; spf=pass (mx1.freebsd.org: domain of markjdb@gmail.com designates 2607:f8b0:4864:20::d41 as permitted sender) smtp.mailfrom=markjdb@gmail.com X-Spamd-Result: default: False [-1.58 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36:c]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[gmail.com:+]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-0.88)[-0.877]; FORGED_SENDER(0.30)[markj@freebsd.org,markjdb@gmail.com]; SUBJECT_ENDS_QUESTION(1.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[markj@freebsd.org,markjdb@gmail.com]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.001]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.002]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-stable@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::d41:from]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-stable] X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2020 18:09:06 -0000 On Tue, Sep 22, 2020 at 07:31:07PM +0200, Peter wrote: > On Tue, Sep 22, 2020 at 12:33:19PM -0400, Mark Johnston wrote: > > ! On Tue, Sep 22, 2020 at 06:08:01PM +0200, Peter wrote: > > ! > my machine should use about 3-4, maybe 5 GB swapspace. Today I found > ! > it suddenly uses 8 GB (which is worryingly near the configured 10G). > ! > > ! > I stopped all the big suckers - nothing found. > ! > I stopped all the jails - no success. > ! > I brought it down to singleuser: it tried to swapoff, but failed. > ! > > ! > I unmounted all filesystems, exported all pools, detached all geli, > ! > and removed most of the netgraphs. Swap is still occupied. > ! > ! > Machine is now running only the init and a shell processes, has > ! > almost no filesystems mounted, has mostly native networks only, and > ! > this still occupies 3 GB of swap which cannot be released. > ! > > ! > What is going on, what is doing this, and how can I get this swapspace > ! > released?? > ! > ! Do you have any shared memory segments lingering? ipcs -a will show > ! SysV shared memory usage. > > I have four small shmem segments from four postgres clusters running. > These should cleanly disappear when the clusters are stopped, and > they are very small. > > Shared Memory: > T ID KEY MODE OWNER GROUP CREATOR CGROUP NATTCH SEGSZ CPID LPID ATIME DTIME CTIME > m 65536 5432001 --rw------- postgres postgres postgres postgres 7 48 4793 4793 6:09:34 18:00:31 6:09:34 > m 65537 0 --rw------- postgres postgres postgres postgres 11 48 6268 6268 6:09:42 10:48:27 6:09:42 > m 65538 0 --rw------- postgres postgres postgres postgres 5 48 6968 6968 6:09:46 18:28:36 6:09:46 > m 65539 0 --rw------- postgres postgres postgres postgres 6 48 6992 6992 6:09:47 3:38:34 6:09:47 > > ! For POSIX shared memory, in 11.4 we do not > ! have any good way of listing objects, but "vmstat -m | grep shmfd" will > ! at least show whether any are allocated. > > There is something, and I don't know who owns that: > $ vmstat -m | grep shmfd > shmfd 13 14K - 473 64,256,1024,8192 > > But that doesn't look big either. That is just the amount of kernel memory used to track a set of objects, not the actual object sizes. Unfortunately, in 11 I don't think there's any way to enumerate them other than running kgdb and examining the shm_dictionary hash table. > Furthermore, this machine is running for quite some time already; it > was running as i386 (with ZFS) until very recently, and I know quite > well what is using much memory: these 3 GB were illegitimate; they > came from nothing I did install. And they are new; this has not > happened before. > > ! If those don't turn anything > ! up then it's possible that there's a swap leak. Do you use any DRM > ! graphics drivers on this system? > > Probably yes. There is no graphics used at all; it just uses "device > vt" in text mode, but it uses i5-3570T CPU (IvyBridge HD2500) graphics > for that, and the driver is "drm2" and "i915drm" from /usr/src/sys (not > those from ports). > Not sure how that would account for 3 GB, unless there is indeed some > leak. I think I see a possible problem in i915, though I'm not sure if you'd trigger it just by using vt(4). It should be fixed in later FreeBSD versions, but is still a problem in 11. Here's a (untested) patch: Index: sys/dev/drm2/i915/i915_gem.c =================================================================== --- sys/dev/drm2/i915/i915_gem.c (revision 365772) +++ sys/dev/drm2/i915/i915_gem.c (working copy) @@ -1863,6 +1863,8 @@ i915_gem_object_truncate(struct drm_i915_gem_objec vm_obj = obj->base.vm_obj; VM_OBJECT_WLOCK(vm_obj); vm_object_page_remove(vm_obj, 0, 0, false); + if (vm_obj->type == OBJT_SWAP) + swap_pager_freespace(vm_obj, 0, vm_obj->size); VM_OBJECT_WUNLOCK(vm_obj); i915_gem_object_free_mmap_offset(obj);