Received: by 10.192.165.148 with SMTP id m20csp4296179imm; Mon, 23 Apr 2018 23:45:07 -0700 (PDT) X-Google-Smtp-Source: AB8JxZosSjyiaW9AKR1KUF7DLFBKaP/omnVGAKi2++t+9TGb64HJe2803bSKjt9SoRi5ets2zUr7 X-Received: by 10.98.189.24 with SMTP id a24mr1443085pff.30.1524552307235; Mon, 23 Apr 2018 23:45:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524552307; cv=none; d=google.com; s=arc-20160816; b=g06wqKKLU4RuhDxSuag0EKt8hxUyNNLg16kXAkCD3TvlbH3Vf1fNxt8f6KlNiYwKPc 8LRAoObOguF3sHOnZyLVKnwd29uzVCtmizK/hD1X8o+n47xjMuU2de6faWTV7eI+N0gC ORpi7k/0MGM6J8+kbg+nWx2mbDo0H+ffGWjk2aEqkFgTYjcbhTWplf5JOFPcZVKu/WcT GtHPR0KD+hwdpARN1X/gJACQYRUyWva+9jI2W5I+Cj3q0lqR9IZTnji4/MKa3q/wGRYh /ocsMFivPba112vGYESY//5yDQLHwB0OjlWGNVJORFU+8d1vs/EdmdPddCj9DxkEX4Vv /O7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=mLDa1hkMQpat+ettIhUtTuKTD+LmImwILjOg2YEErD0=; b=q3TNYXblxFhDirYIuY3yVNaLVZXHClsts24xjq24YLideH12il9H09Tq4pgxHFt+sg AmHaq0KoSQPEOchC69amlUr74FA4gv8duduzehtIx/UcizBQxdjaUcOgcxgUmKix//R/ UE4aOg+3VDSOH+WoJTl3dZpNVJfaIjpPpgXgc0eCEfobkbfkf278fuIOyra8t7Hbd+S5 8JDLJTuD5sMCO3ZfV7HqGWaGe09Ee7roL/D+SYawu8PfqpVi3aSQOPr//cEo507cWVB4 mnxylLAlV1kB4NlvVllTl7A4sDbv30k/OEeLlkxaBbQ5iaMCPYBrPl9QLuAsJnw5E/K0 IAug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33-v6si10648803plu.385.2018.04.23.23.44.53; Mon, 23 Apr 2018 23:45:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756344AbeDXGnG (ORCPT + 99 others); Tue, 24 Apr 2018 02:43:06 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:53654 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755936AbeDXGkl (ORCPT ); Tue, 24 Apr 2018 02:40:41 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3O6d9lV037736 for ; Tue, 24 Apr 2018 02:40:40 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0b-001b2d01.pphosted.com with ESMTP id 2hhvkwxay0-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 24 Apr 2018 02:40:39 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 24 Apr 2018 07:40:38 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 24 Apr 2018 07:40:34 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3O6eXfb7733538; Tue, 24 Apr 2018 06:40:33 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 46E125204D; Tue, 24 Apr 2018 06:31:13 +0100 (BST) Received: from rapoport-lnx (unknown [9.148.8.99]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id B795B52049; Tue, 24 Apr 2018 06:31:11 +0100 (BST) Received: by rapoport-lnx (sSMTP sendmail emulation); Tue, 24 Apr 2018 09:40:31 +0300 From: Mike Rapoport To: Jonathan Corbet Cc: Andrew Morton , Andrea Arcangeli , linux-doc , linux-mm , lkml , Mike Rapoport Subject: [PATCH 1/7] mm/ksm: docs: extend overview comment and make it "DOC:" Date: Tue, 24 Apr 2018 09:40:22 +0300 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524552028-7017-1-git-send-email-rppt@linux.vnet.ibm.com> References: <1524552028-7017-1-git-send-email-rppt@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18042406-0008-0000-0000-000004EE858A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18042406-0009-0000-0000-00001E82ACCA Message-Id: <1524552028-7017-2-git-send-email-rppt@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-24_01:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804240067 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The existing comment provides a good overview of KSM implementation. Let's update it to reflect recent additions of "chain" and "dup" variants of the stable tree nodes and mark it as "DOC:" for inclusion into the KSM documentation. Signed-off-by: Mike Rapoport --- mm/ksm.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/mm/ksm.c b/mm/ksm.c index 58c2741..54155b1 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -51,7 +51,9 @@ #define DO_NUMA(x) do { } while (0) #endif -/* +/** + * DOC: Overview + * * A few notes about the KSM scanning process, * to make it easier to understand the data structures below: * @@ -67,6 +69,21 @@ * this tree is fully assured to be working (except when pages are unmapped), * and therefore this tree is called the stable tree. * + * The stable tree node includes information required for reverse + * mapping from a KSM page to virtual addresses that map this page. + * + * In order to avoid large latencies of the rmap walks on KSM pages, + * KSM maintains two types of nodes in the stable tree: + * + * * the regular nodes that keep the reverse mapping structures in a + * linked list + * * the "chains" that link nodes ("dups") that represent the same + * write protected memory content, but each "dup" corresponds to a + * different KSM page copy of that content + * + * Internally, the regular nodes, "dups" and "chains" are represented + * using the same :c:type:`struct stable_node` structure. + * * In addition to the stable tree, KSM uses a second data structure called the * unstable tree: this tree holds pointers to pages which have been found to * be "unchanged for a period of time". The unstable tree sorts these pages -- 2.7.4