From owner-freebsd-hackers@freebsd.org Sun Nov 18 12:11:52 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5AD101137E60 for ; Sun, 18 Nov 2018 12:11:52 +0000 (UTC) (envelope-from sblachmann@gmail.com) Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 415047A8B2; Sun, 18 Nov 2018 12:11:51 +0000 (UTC) (envelope-from sblachmann@gmail.com) Received: by mail-oi1-x22f.google.com with SMTP id u18so4945017oie.10; Sun, 18 Nov 2018 04:11:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=T/DIoXoeLEpuWrVeCQ+RorkrmTrE7/L8UxLH0t7vL2I=; b=mThDViwboKMeZVjk0S17wtSLHwqOirRs3f3FUd0wjjWjruANPGa8hghC0LZW1U/rcW uACNQg+4ZFsI+u2Y5WIaXrRRwCwfJwYGD4jLbtqupIYuN/tje+CO0v3uORfSmsHf/pnB WK57IRdwGCqkt2qRAaxyqNTHe0vd50x5sFnCE9Pp3O2wiT8vklxqRKD5JsFefMAlrDjL PjeFFCiMp6UtKr9mz/bRRebqeRWdjXZjjewDVszZLpX1sPxyF2sB6hVuNzKd8opdaVHn GTZVg/tWgUjoXGDobItjPPy8Z5d/rpNr4f4HQGpbZ48aHXO61UJJ7Q2wgqzyouVoVnEv ZlRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=T/DIoXoeLEpuWrVeCQ+RorkrmTrE7/L8UxLH0t7vL2I=; b=ckc8Jw1IoZBjSyVrSHaQVr3UUQTG7Oahw58effPEWB24N3tCV0mjI1U5wFIqbWm0aj e+cw/AH3oc07edQmi+Xqi3cnUf0gh1rfYtcsAss+MIJx60HK/EZH3AsAR3cLP17pd/oZ KgdaGYXYFlspsSh2kphx4VDGKqjPUnnPKkkwL3vI4/3L2b3oh/vIAo5hgens8308rqpC +sCCY3zYVtUjJsmFb1kDkJ8bSoBzUeJ7JZ+Ke7qpWKpGaVbsAlvNiiCCYhHqawMjZLFt h6zCXumY4udhwkjTcUFu0Zt4SqZMgngcB0SW52MgU4a/hN7DXrOFDz8IeeOtW5cl7+4k 5wDw== X-Gm-Message-State: AGRZ1gJLTTTqlrpfKTzgPy/M63dcDNaYX3HpU7qHdIxkjyr+Q4/RdR2Y 50uRjqaGFjtNHetVEdWuzropycIKWO4vHuTPCGQ= X-Google-Smtp-Source: AJdET5e+gHe165376dWnf6tQ5rk6y0/UJwbX9+lYC5dgcTUFsOWYlAa5KO0Xjl2F/4bN86CrJBpcKst7BjBot5VHv1Q= X-Received: by 2002:aca:3b89:: with SMTP id i131-v6mr4722570oia.242.1542543110302; Sun, 18 Nov 2018 04:11:50 -0800 (PST) MIME-Version: 1.0 Received: by 2002:ac9:3052:0:0:0:0:0 with HTTP; Sun, 18 Nov 2018 04:11:49 -0800 (PST) In-Reply-To: <201811180154.wAI1smhg049214@slippy.cwsent.com> References: <201811180154.wAI1smhg049214@slippy.cwsent.com> From: Stefan Blachmann Date: Sun, 18 Nov 2018 13:11:49 +0100 Message-ID: Subject: Re: 13-CURRENT: several GB swap being used despite plenty of free RAM To: Cy Schubert Cc: Mark Millard , Rebecca Cran , freebsd-hackers Hackers , Mark Johnston , Ian Lepore , Wojciech Puchar Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 415047A8B2 X-Spamd-Result: default: False [-2.75 / 15.00]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[gmail.com]; FROM_HAS_DN(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; MIME_GOOD(-0.10)[text/plain]; IP_SCORE(-0.88)[ipnet: 2607:f8b0::/32(-2.58), asn: 15169(-1.75), country: US(-0.10)]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; MX_GOOD(-0.01)[cached: alt3.gmail-smtp-in.l.google.com]; DKIM_TRACE(0.00)[gmail.com:+]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_IN_DNSWL_NONE(0.00)[f.2.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; NEURAL_HAM_SHORT(-0.86)[-0.858,0]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FREEMAIL_CC(0.00)[yahoo.com] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Nov 2018 12:11:52 -0000 The inconveniences that the new swapping strategy causes are a regular topic in the FreeBSD forums. Desktop users complain about lagginess, server users complain of long delays because server processes intended to be kept in memory for quick response times got swapped out and need to be swapped in again, resulting in outrageously poor server performance in spite of plenty of unused memory. Turning off swap completely, as Cy Schubert suggests, is strongly discouraged in the forums, as it can lead to kernel panicking because of being unable to swap out in critical kernel memory shortage situations, leading to the risk of very serious filesystem corruption. However, Cy Schubert is probably right when stating that the new swapping strategy resembles the 1960s-1980s industry's main swapping strategy. The bad thing is now, that nowadays memory is no longer scarce and people can dimension their memory such that under normal circumstances there will never be any need to swap. So I guess the unwillingness of the developer team to add an option like "NoPreemptiveSwapping", which disables swapping out as long as there is free physical memory available, is of psychological nature. Lacking such an option, there is still the possibility to use rctl to disable swapping for particular users, processes, jails etc to mitigate the problems caused by the new swapping strategy to some degree. On 11/18/18, Cy Schubert wrote: > In message , Mark > Millard via f > reebsd-hackers writes: >> On 2018-Nov-17, at 16:13, Mark Johnston wrote: >> > >> > On Sat, Nov 17, 2018 at 04:59:48PM -0700, Ian Lepore wrote: >> >> On Sat, 2018-11-17 at 22:52 +0100, Wojciech Puchar wrote: >> >>> freebsd will not swap with that lots of free ram. >> >>> but it's 90GB free NOW, how about before? >> >>> >> >> >> >> Your information is outdated. For at least a couple years now (since >> >> approximately the 10.1 - 10.2 timeframe is my vague estimate), freebsd >> >> will page out application memory that hasn't been referenced for some >> >> time, even when the system has no shortage of free memory at all. >> > >> > No, FreeBSD will only ever swap when there is a free page shortage. >> > The >> > difference is that we now slowly age unreferenced pages into the >> > inactive queue, which makes them candidates for pageout and subsequent >> > eviction. With pageout_update_period=0, anonymous memory won't get >> > paged out unless there's a shortage of inactive pages, or an >> > application >> > calls madvise(MADV_DONTNEED) on a range of memory (which moves any >> > backing pages to the inactive queue). >> >> Swapping is built on top of paging as I understand. The system >> can page without swapping but can not swap without (effectively) >> paging to implement the swapping, if I understand right. If I >> understand right, swapped-out means that kernel stacks have >> been written out and have to be loaded back in RAM before the >> process/threads can even run. (I might not understand.) >> >> If I've got that right, are there distinctions here for >> paging that is not part of swapping vs. actual swapping >> (and its use of paging)? Saying that something does not >> swap does not necessarily imply that it does not page: >> it still could have paging activity that does not include >> moving the kernel stacks for the process to backing media? > > This is generally the old-school definition, IIRC third year comp sci, > original BSD definition, which was also the way IBM defined it for MVS. > (IBM also virtually swapped out address spaces, not written to DASD, as > a means to deny CPU cycles through the scheduler not given the chance > to consider the tasks (threads) in the address space). > > You can disable swapping by setting vm.swap_enabled=0. > >> >> At times I have trouble interpreting when wording goes back >> and forth between swapping and paging, both for the intended >> meaning and for the technical implications. >> >> >> The advice I was recently given to revert to the old behavior is: >> >> >> >> sysctl vm.pageout_update_period=0 >> >> >> >> I've been using it on a couple systems here for a few days now, and so >> >> far results are promising, I am no longer seeing gratuitous swapfile >> >> usage on systems that have so much free physical ram that they should >> >> never need to page anything out. I haven't yet pushed one of those >> >> systems hard enough to check what happens when they do need to start >> >> proactively paging out inactive memory due to shortages -- it could be >> >> that turning off the new behavior has downsides for some workloads. >> >> >> >> >> === >> Mark Millard >> marklmi at yahoo.com >> ( dsl-only.net went >> away in early 2018-Mar) >> >> _______________________________________________ >> freebsd-hackers@freebsd.org mailing list >> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers >> To unsubscribe, send any mail to >> "freebsd-hackers-unsubscribe@freebsd.org" >> > > -- > Cheers, > Cy Schubert > FreeBSD UNIX: Web: http://www.FreeBSD.org > > The need of the many outweighs the greed of the few. > > > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" >