From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.3 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D07E0C33CB1 for ; Sun, 19 Jan 2020 10:59:40 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 920282053B for ; Sun, 19 Jan 2020 10:59:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jmKaG5Yx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 920282053B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.92.3) (envelope-from ) id 1it8Ic-0005Jc-8I; Sun, 19 Jan 2020 05:59:22 -0500 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by shelob.surriel.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.3) (envelope-from ) id 1it8Ia-0005JW-G1 for kernelnewbies@kernelnewbies.org; Sun, 19 Jan 2020 05:59:20 -0500 Received: by mail-lf1-x129.google.com with SMTP id y1so21712960lfb.6 for ; Sun, 19 Jan 2020 02:59:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Til7mY6UH7ptmlUMbyjM6+iGJJjgrCexAng+9/bklao=; b=jmKaG5YxKrLKtUHeAlDXyp65vSqKBiR0QvTdO8AFEg/qAYxF/SispEoVR7QQOjaaA1 0Uouhb7O5OKZC81rt1BAKhRvoMgRc+fTSPwFDqFbcFlT2p64X/tjlRfFxE36KxksJVLx rFwXKho+w42Xvwr7LlIsrx7yCF7iT2+S4hSw0HE4Ynjwg1RSOBp96k1hpXaHo5bwLw2I UUBDqjy5wvFd7o2r3kpN9rrrWv6GAXvzTjiCSY/VqECW+Lm5Noa6f/ldmbtQTqrdwsx/ Qz4Zy+oSWlJW/cooujw/BiVYPNdJsExhyckSASszdsyQy4kzvNsxKUxwiE0vOeB17hIG TUCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Til7mY6UH7ptmlUMbyjM6+iGJJjgrCexAng+9/bklao=; b=O4hSPIlz5MQWmFjH1BE/3BsV/zd6JvLGwIL1hAI1W6Pcy0kpUZf2qRFrWhK6i5m4Ke B6hs657WUJMX0upKgN3AfjCaciburHMqcX/Z7a6Iqm+WcJaqSB48wKqVa7/QOhLoJRMr 2Mh7NKkBsKNGnGmyuT6exRTZCADDNvITmp6O5rGSxPUc8Z2WlMzfs7DBe59w8gdl6jQQ tgsExhwgHEzSZ6HZg4icaAl7z2jTVVdAkA8JTW0T2FEbBcwkDkjTCUTYic6yrEkqMQkK SW2rNxQ7SPhchvd6SrI4Y9Gbv9KPp2gx4Q0DlA9L00tQ/paNrO3qSK0nwxFK9RFwiYsD W9TA== X-Gm-Message-State: APjAAAUX2YFlfzfG6dXPpuBhNGKKx5ToNvlhYaCcRQ/AKx2sKuXvrmUI n9zk3zOAkOMDmairz6pL9EMooAr6FSEAXDKkb4w= X-Google-Smtp-Source: APXvYqybcU6ztKK5rUdnbaNXYRpmb5OAkhs9xEdRSQEqHvdBRJaCVTTUM3FkjUZtAyTh4PEuzH2kTXq4odl0bsmz8/Y= X-Received: by 2002:a19:844:: with SMTP id 65mr9296169lfi.20.1579431556487; Sun, 19 Jan 2020 02:59:16 -0800 (PST) MIME-Version: 1.0 References: <412530.1579360214@turing-police> In-Reply-To: <412530.1579360214@turing-police> From: Anupam Kapoor Date: Sun, 19 Jan 2020 10:55:44 +0000 Message-ID: Subject: Re: transfer physical memory page to swap disk To: =?UTF-8?Q?Valdis_Kl=C4=93tnieks?= Cc: Sumit Kumar , kernelnewbies X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============2560155475691030822==" Errors-To: kernelnewbies-bounces@kernelnewbies.org --===============2560155475691030822== Content-Type: multipart/alternative; boundary="000000000000df1fb3059c7c1073" --000000000000df1fb3059c7c1073 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 15 Jan 2020 18:23:05 +0530, Anupam Kapoor said: >> On Wed, 15 Jan 2020 at 6:02 PM Sumit Kumar wrote= : >>> Does C/C++ provide any API / system call that enables user to force the >>> application to transfer some its physical pages to swap disk ? If so, is it >>> also possible to obtain the least used page using some API ? >> would madvise not serve your needs ? > There's this word "force" in the question. > The problem is that madvise() is *advice* to the kernel, not a strict > guarantee. There's a difference between "If you need to move pages > to disk, consider these pages first" and "Move them to disk now, whether > you really wanted to or not". ofcourse (afaik) there is no way for the application to force the *kernel* to do something like this. but if _all_ that is required is randomly unmapping some marked application pages, _that_ can be naively 'done' by the application itself :) for example, have a list of unmappable pages and an unmapper thread which does the unmapping for you (picking any element in the list at random) -- kind regards anupam In the beginning was the lambda, and the lambda was with Emacs, and Emacs was the lambda. On Sat, Jan 18, 2020 at 3:10 PM Valdis Kl=C4=93tnieks wrote: > On Wed, 15 Jan 2020 18:23:05 +0530, Anupam Kapoor said: > > On Wed, 15 Jan 2020 at 6:02 PM Sumit Kumar > wrote: > > > Does C/C++ provide any API / system call that enables user to force t= he > > > application to transfer some its physical pages to swap disk ? If so, > is it > > > also possible to obtain the least used page using some API ? > > would madvise not serve your needs ? > > There's this word "force" in the question. > > The problem is that madvise() is *advice* to the kernel, not a strict > guarantee. There's a difference between "If you need to move pages > to disk, consider these pages first" and "Move them to disk now, whether > you really wanted to or not". > > --000000000000df1fb3059c7c1073 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, 15 Jan 2020 18:23:05 +0530, Anupam Kapoor said:
>= ;> On Wed, 15 Jan 2020 at 6:02 PM Sumit Kumar <sumit686215@gmail.com> wrote:
>>> Doe= s C/C++ provide any API / system call that enables user to force the
>= ;>> application to transfer some its physical pages to swap disk ? If= so, is it
>>> also possible to obtain the least used page usin= g some API ?

>> would madvise not serve your needs ?

= > There's this word "force" in the question.

> T= he problem is that madvise() is *advice* to the kernel, not a strict
>= ; guarantee.=C2=A0 There's a difference between "If you need to mo= ve pages
> to disk, consider these pages first" and "Move t= hem to disk now, whether
> you really wanted to or not".

ofcourse (afaik) there is no way for the application to f= orce the
*kernel* to do something like this.=C2=A0

but if _all_ t= hat is required is=C2=A0randomly unmapping some marked=C2=A0
application p= ages, _that_ can be naively 'done' by the application=C2=A0
itself= :)=C2=A0

for example, have a list of unmappable pages and an unmapp= er thread=C2=A0
which does the unmapping for you (picking any element in t= he list=C2=A0
at random)=C2=A0

--
kind regards
anupam

In th= e beginning was the lambda, and the lambda was with Emacs, and Emacs was th= e lambda.


On Sat, Jan 18, 2020 at 3:10 P= M Valdis Kl=C4=93tnieks <vald= is.kletnieks@vt.edu> wrote:
On Wed, 15 Jan 2020 18:23:05 +0530, Anupam Kapoor said:<= br> > On Wed, 15 Jan 2020 at 6:02 PM Sumit Kumar <sumit686215@gmail.com> wrote: > > Does C/C++ provide any API / system call that enables user to for= ce the
> > application to transfer some its physical pages to swap disk ? If= so, is it
> > also possible to obtain the least used page using some API ?
> would madvise not serve your needs ?

There's this word "force" in the question.

The problem is that madvise() is *advice* to the kernel, not a strict
guarantee.=C2=A0 There's a difference between "If you need to move= pages
to disk, consider these pages first" and "Move them to disk now, = whether
you really wanted to or not".

--000000000000df1fb3059c7c1073-- --===============2560155475691030822== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies --===============2560155475691030822==--