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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA16BE81DE8 for ; Fri, 6 Oct 2023 12:01:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E7FB6B02CE; Fri, 6 Oct 2023 08:01:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 498226B02CF; Fri, 6 Oct 2023 08:01:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 360116B02D0; Fri, 6 Oct 2023 08:01:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 27EA76B02CE for ; Fri, 6 Oct 2023 08:01:29 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id E60D7B488A for ; Fri, 6 Oct 2023 12:01:28 +0000 (UTC) X-FDA: 81314896656.20.4712940 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 56F33100028 for ; Fri, 6 Oct 2023 12:01:24 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Pb33aTMT; spf=pass (imf05.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696593684; a=rsa-sha256; cv=none; b=HvZ9ZQPzCGXhnQjJWDDe5En53ecs41XQUSyQAJiRe0Pr8kU2fXFVEKnEPKdpfokeUHpV2o ItAifRdF8VjFSO3XzX+Hprdbz3mP35sXo2kDhmhPE9U8TyUz8y6TgEOuuY94+RRqYvu3RN djm4REGXrqKNzzc81QnzGAYKXk04yh4= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Pb33aTMT; spf=pass (imf05.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696593684; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=kCYNyulRpx1YyhVOL3Le9TlBc2wHmh6Ikm1+wxMUQTM=; b=1eoik7zCvlymmn1zoS9P07rFfIO4bpPhmt1yMj2X/hejPzxXUmOiz5DihAzC0gmbRulAon ns4s6xjt+qG9B24bR3tBhHBGCdhJWkFryMPow4Wr+nG+pjGQRlP8OjENNWzVS4ygi5uCpi bQiL2R4Dn4Tb0BX6tQsfBwUVgiIA6lk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696593683; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kCYNyulRpx1YyhVOL3Le9TlBc2wHmh6Ikm1+wxMUQTM=; b=Pb33aTMTE770OMxsdIrKeFCeZEJXAFePH7BW/u+G8Y5VEeIjlySfhcfpvM9IlZ2DPb7xO4 dRbs5T9hOv/AwYv9EBM14CyeI3rM8oCY19EWvB0579o19ajsGM4F9+pprB3iFbrO7UQ0yW nMjL9IYS3emeBXJb/0ScDkNKvHeQAcU= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-21-q5dagWBsPtWc9326hr5oKQ-1; Fri, 06 Oct 2023 08:01:16 -0400 X-MC-Unique: q5dagWBsPtWc9326hr5oKQ-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3231f43fc5eso1346352f8f.2 for ; Fri, 06 Oct 2023 05:01:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696593671; x=1697198471; h=content-transfer-encoding:in-reply-to:subject:organization:from :references:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=kCYNyulRpx1YyhVOL3Le9TlBc2wHmh6Ikm1+wxMUQTM=; b=ZK4cZ3sJ1GxdS29oU9hlBbafDiy9+ESaKFl11D7Za5zwgLUpT1r/ssjBUx/3xP61FT Wno/2BjOhigKJLgc/v5kUV86+0uN0rarZPBZ7tSnMOFfUs9uSnh9KtIRBhY06diiJFu4 v8Ot76VT9w88FzsKlvTGW/xKud+xgNf4+MtDBIAQUsXYVDFIE3QA4zGFK89pVemtZdsV ySB0VRYsh82KPvBcpmbRQzL/fxp7pvhO/1Mc0YHG4YSe0y5mvMjuFv1esFvEZ+F215hU NV95f+WOcStUbYX4vneZ4O+ZYpBeEfHZSPQUt+rTJf3xcqMfXX5/zLanxuFNJkwg1ZWG Adtg== X-Gm-Message-State: AOJu0YxyuK4n3c2jjCo5O1XZwnXchDqQAK4VXYwC1wJM8ImRgriIMvyC UeqLoeNlkQER3FVFnlSCOFP9YDfT0uypjrNsGVU/EFlp1lPL0UTjR/1a+lYAbEqpfNOSq8DoN+X djfcctqCjRN/UVD0LNJI= X-Received: by 2002:adf:ea8f:0:b0:317:6175:95fd with SMTP id s15-20020adfea8f000000b00317617595fdmr7669952wrm.43.1696593670824; Fri, 06 Oct 2023 05:01:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGIHkTSWEYQCqhtcnXwQbXXcji0NvYj5HwDLBbmOfLGxJeobULC9BGehmgcvKkiU172hpNvnA== X-Received: by 2002:adf:ea8f:0:b0:317:6175:95fd with SMTP id s15-20020adfea8f000000b00317617595fdmr7669924wrm.43.1696593670256; Fri, 06 Oct 2023 05:01:10 -0700 (PDT) Received: from ?IPV6:2003:cb:c715:ee00:4e24:cf8e:3de0:8819? (p200300cbc715ee004e24cf8e3de08819.dip0.t-ipconnect.de. [2003:cb:c715:ee00:4e24:cf8e:3de0:8819]) by smtp.gmail.com with ESMTPSA id m15-20020adfe94f000000b0031984b370f2sm1500366wrn.47.2023.10.06.05.01.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Oct 2023 05:01:09 -0700 (PDT) Message-ID: <4509a3b4-16a6-f63e-1dd5-e20c7eadf87d@redhat.com> Date: Fri, 6 Oct 2023 14:01:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 To: Stefan Roesch , kernel-team@fb.com Cc: akpm@linux-foundation.org, hannes@cmpxchg.org, riel@surriel.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20231004190249.829015-1-shr@devkernel.io> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v1 0/4] mm/ksm: Add ksm advisor In-Reply-To: <20231004190249.829015-1-shr@devkernel.io> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 56F33100028 X-Stat-Signature: ir99dxzc5rp4be9635itcno5cpqawox9 X-Rspam-User: X-HE-Tag: 1696593684-312162 X-HE-Meta: U2FsdGVkX19ZNrDJOu1D31aI0rDeLqRdz1iysnbjIQ0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zAZ9h9+868H/J+pW7z9wcbXApW/wpmC9I/hs1MUYmIFc1wnsiSmrJSzeah8ZPCU4rTlLQupWXy6Kw2p9PJQfMOHSQD8me7O8H5DSyErUtKcy5KPSyKLb61/Xv9AB6SwWFrUw3XfmXcT80XRjAUX/Y9d0FrDSgx+M8YD2FTdO1YAHiJboM5BDJZM4FNk32cER99RKgdPAhx091D8ONMMn9x//4LoEXf/8yGYk42p9raiYoM6BUOUSevFTJTWa9YJD7qLQSjj X-Bogosity: Ham, tests=bogofilter, spamicity=0.000088, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 04.10.23 21:02, Stefan Roesch wrote: > What is the KSM advisor? > ========================= > The ksm advisor automatically manages the pages_to_scan setting to > achieve a target scan time. The target scan time defines how many seconds > it should take to scan all the candidate KSM pages. In other words the > pages_to_scan rate is changed by the advisor to achieve the target scan > time. > > Why do we need a KSM advisor? > ============================== > The number of candidate pages for KSM is dynamic. It can often be observed > that during the startup of an application more candidate pages need to be > processed. Without an advisor the pages_to_scan parameter needs to be > sized for the maximum number of candidate pages. With the scan time > advisor the pages_to_scan parameter based can be changed based on demand. > > Algorithm > ========== > The algorithm calculates the change value based on the target scan time > and the previous scan time. To avoid pertubations an exponentially > weighted moving average is applied. > > The algorithm has a max and min > value to: > - guarantee responsiveness to changes > - to avoid to spend too much CPU > > Parameters to influence the KSM scan advisor > ============================================= > The respective parameters are: > - ksm_advisor_mode > 0: None (default), 1: scan time advisor > - ksm_advisor_target_scan_time > how many seconds a scan should of all candidate pages take > - ksm_advisor_min_pages > minimum value for pages_to_scan per batch > - ksm_advisor_max_pages > maximum value for pages_to_scan per batch > > The parameters are exposed as knobs in /sys/kernel/mm/ksm. > By default the scan time advisor is disabled. What would be the main reason to not have this enabled as default? IIUC, it is kind-of an auto-tuning of pages_to_scan. Would "auto-tuning" describe it better than "advisor" ? [...] > How is defining a target scan time better? > =========================================== > For an administrator it is more logical to set a target scan time.. The > administrator can determine how many pages are scanned on each scan. > Therefore setting a target scan time makes more sense. > > In addition the administrator might have a good idea about the > memory sizing of its respective workloads. Is there any way you could imagine where we could have this just do something reasonable without any user input? IOW, true auto-tuning? I read above: > - guarantee responsiveness to changes > - to avoid to spend too much CPU whereby both things are accountable/measurable to use that as the input for auto-tuning? I just had a family NMI, so my todo list is quite lengthy. Hoping I cna take a closer look next week. -- Cheers, David / dhildenb