Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp961202lqo; Sat, 11 May 2024 01:12:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVml0c6RKXV0Ibyrv+T66fBLur6J7DMFc9zm1kgrr5sMVR+grbeUZPDC6kUVOVU8TJZu5J2WfWe6RsBrlS2IOPnB8ovjFgdeSKvIAfpbQ== X-Google-Smtp-Source: AGHT+IESjhVu8uxFEs53teRVHqJfG2QjdUSpHCpwo6buMu2xBBYWYhz2cxsQuiZfX31arUt9ptCC X-Received: by 2002:a17:902:7b82:b0:1ec:585e:5363 with SMTP id d9443c01a7336-1ef43d2e2ffmr41171145ad.29.1715415160938; Sat, 11 May 2024 01:12:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715415160; cv=pass; d=google.com; s=arc-20160816; b=dZLoiGnMZF6e8ahqbylDXIk2QR6P0LgqGvznfJW1Ppm62Lx0E7OwwfBAGCdGgUeTXQ fiBygTC0rBzvcNNOx+VVReBvEBwh3GA0KXeIsGcFTjAQhrz1dJliv+qf9OXLZotMVasD lOFU2IoTDIQRIaPgtFESm+UL8B0xBV1uTx1fQcVh/xdOKc8JKCFNntgH9LY08rfW4Dc4 KDynDC8ovHVs4VagMvKIg/ICuEH9q6q3e4qOYBLAR77ZckNJQr69uc05C8sa340Mw4Kt 0A+6ICez0MPNwK2NKLq5xBr+Az5Jf+pzG1hPv9ZNJCv5xifUlQn4DDr8VhN+e3T3dBMX csmQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=9qBbsDAPUy5FGaDuBuioErI1+pT2h8H+WItqDsVZoLo=; fh=pDh9hYPRR1WS3bdxoCwNvWjQxci/QFv8985WBz/ZosQ=; b=nGWw0baxbhANyaT0U5G6Rp5my/mDx9EL+7vP0J1VChur0Q72wdD7HDE8bX23xScSXl jffWu0HPcvitPuyfO4g1Q+wh83Dxw6d7YMkNYb0M1G4cgxDucncLHF3eQWEeT8z26G9v VMJFXjCPBJIobchAm5+0znibb+n8rbnGnWidzG+tOGkrQSON5nb1+jjXDNz0RtHw/xKA dV36qU9i1b1jbhBzefJt3zC23xQ7dLSMPlztLQh7AQ6MGnRsOkg1KoHQgWH9SO+btt7b eqwEjVOVuPrbKfV3ChWKF86mmMI8DqJJwSr9yKAkjrUvfY1+rHmtTPAU31bc3wTIH4Tg WjUQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=I3wXGJNL; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-176457-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176457-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0c0373fbsi49842595ad.345.2024.05.11.01.12.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 01:12:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-176457-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=I3wXGJNL; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-176457-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176457-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 80CC62842AD for ; Sat, 11 May 2024 08:12:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BA2AC37147; Sat, 11 May 2024 08:12:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="I3wXGJNL" Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A653611190; Sat, 11 May 2024 08:12:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.196 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715415149; cv=none; b=I4Ixya/QWfuXcqQQ0jM5Qsegq4BMK49vcWg5H2GaUFGHyCYyl6InUUkspgvimNU3Ko2CKZ4xg56mOGpuyDkQsnSbYh7KJkz929ALDTzt2T6ln/qPNBFwNskC3pcyAOu3n3sAvZo4CUrj8qV2teNxPmrqNAnsTvwzTzVLIaJpKNI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715415149; c=relaxed/simple; bh=+5Xg93Nnj+GcdyudDCY16biOFb/0HIlATV7kqqR0IP8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q7GG93dvDbFHLdGtvVUqlw1Bxrr3XJk6NVy6YgYoI8UBST612Zm99AFRBi9shSMNlhhdKrAa0U+q3atUBqz9hidBj9lQulloWcRqUcKsuJhnpxSiBo+2Kllxj6aKvPUEazQO462SsCt0RRgHstmIQ8qsipjzbCkLkmYQKLHHWKQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=I3wXGJNL; arc=none smtp.client-ip=209.85.215.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f196.google.com with SMTP id 41be03b00d2f7-5ff57410ebbso2285528a12.1; Sat, 11 May 2024 01:12:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715415148; x=1716019948; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9qBbsDAPUy5FGaDuBuioErI1+pT2h8H+WItqDsVZoLo=; b=I3wXGJNLjX1Dr8vRIrA5dUKKjZ2tT+lKamvd9TdKzoiJVa2QB9+W/3SLp5x9rh4G+A xq9ZtEqkzOV25/oOGDsqFR7l65gbcazgE04km9LiLA1hxSnPiwzw/kXtwdD2M5NbM1lO 5j5SKqkowPOLmAfARsPXfS4j8cNwkSCEKrhDcb/tdKQtohF6rE2XXyKzpqXCDyWeBEuO P1QYMs753KKjCAav/u0KgTHE5I+k7yGkmTlfuqdn6eH5PXR/XK9EIe/AxUofI/a1k3U5 w2LIdjU8z7IQgVmlld46as+hzADzlTb3q3JTEGeR5N55ROZbsT1G2UeLncpe9loVIh55 BNFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715415148; x=1716019948; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9qBbsDAPUy5FGaDuBuioErI1+pT2h8H+WItqDsVZoLo=; b=Wg865X0Vcfyr6+tb6/x+zpof6vWVTeykeen1uwsXFAFQwFDRai2ImZGWNfD4Iar6w3 TxB3X9L3b801jl/Y26oc3mD+VzIGA+Hx+C89NeFepOmxi6cBDbQYsXt1W0puv0iaRcH/ jr2GovWWXyWoqSIibRHYdVGkWm9Q4bRZ5/kBNj+A4FWqtxiElx5+LAfwrP99GKffpVC8 V26p8k3bastdY82H6YBEHcYxzbjF38SHBMyqWfC7owqxBaZmoMhhjFPCJBQFt5V+yGUH 8ragWmkYoAJfaaq4fYzrvGLo5A3bSaaCQx1JyBBVLBkxZLvqfDeg8HT/JwC9sVFrl/RT 4+WQ== X-Forwarded-Encrypted: i=1; AJvYcCW2XHd98f6SHWviT8b1pFRo458bmk5x8K7/zsenl4g7Z88rxfkq43cTWMgPoK6oRpHh3EnkPZcN30NWJZPF+ei541Ho8pkEcsGpZLJb62mCv+3djh20U9Ne70bHOYH8BHOCv275h1Dab/jUfw== X-Gm-Message-State: AOJu0YyXL7H62lIBZPpZrxU+pQt/FFV8u0vynQa80h2+l0WJDjevkzLw pBgjk3kk+I+xXu/famtf260TF18G426yumnJEbypEKwp/ZycHX/d X-Received: by 2002:a17:903:22cc:b0:1e5:4f00:3751 with SMTP id d9443c01a7336-1ef43c0cf2amr62507595ad.3.1715415147903; Sat, 11 May 2024 01:12:27 -0700 (PDT) Received: from localhost.localdomain ([193.203.214.57]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0c256a0csm43968605ad.306.2024.05.11.01.12.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 01:12:27 -0700 (PDT) From: xu xin X-Google-Original-From: xu xin To: david@redhat.com Cc: akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, shr@devkernel.io, si.hao@zte.com.cn, xu.xin16@zte.com.cn Subject: Re: [PATCH linux-next v2] ksm: add ksm involvement information for each process Date: Sat, 11 May 2024 08:12:24 +0000 Message-Id: <20240511081224.637842-1-xu.xin16@zte.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit >> @@ -3217,6 +3217,10 @@ static int proc_pid_ksm_stat(struct seq_file *m, struct pid_namespace *ns, >> seq_printf(m, "ksm_zero_pages %lu\n", mm->ksm_zero_pages); >> seq_printf(m, "ksm_merging_pages %lu\n", mm->ksm_merging_pages); >> seq_printf(m, "ksm_process_profit %ld\n", ksm_process_profit(mm)); >> + seq_printf(m, "KSM_mergeable: %s\n", >> + test_bit(MMF_VM_MERGEABLE, &mm->flags) ? "yes" : "no"); > >All it *currently* means is "we called __ksm_enter()" once. It does not >mean that KSM is still enabled for that process and that any VMA would >be considered for merging. > >I don't think we should expose this. > >That information can be more reliably had by looking at > >"/proc/pid/smaps" and looking for "mg". > >Which tells you exactly if any VMA (and which) is currently applicable >to KSM. > > >> + seq_printf(m, "KSM_merge_any: %s\n", >> + test_bit(MMF_VM_MERGE_ANY, &mm->flags) ? "yes" : "no"); > >This makes more sense to export. It's the same as reading >prctl(PR_GET_MEMORY_MERGE). > >The man page [1] calls it simply "KSM has been enabled for this >process", so process-wide KSM compared to per-VMA KSM. > >"KSM_enabled:" > >*might* be more reasonable in the context of PR_SET_MEMORY_MERGE. > >It wouldn't tell though if KSM is enabled on the system, though. > I agree it. But I hope admistrators can tell if the process enabled KSM-scan by madvise or prctl. At this point, only "/proc/pid/smaps" is not enough. So can we add a item "KSM_enabled" which has three value as follows? 1) "prctl": KSM has been fully enabled for this process. 2) "madvise": KSM has been enabled on parts of VMA for this process. 3) "never": KSM has been never enabled for this process. Just refer to the semantics of '/sys/kernel/mm/transparent_hugepage/enabled'