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 4065DC001B0 for ; Tue, 15 Aug 2023 08:51:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C2E818D0006; Tue, 15 Aug 2023 04:51:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BDF588D0001; Tue, 15 Aug 2023 04:51:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA5668D0006; Tue, 15 Aug 2023 04:51:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 9A3208D0001 for ; Tue, 15 Aug 2023 04:51:38 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 671DF1C9C53 for ; Tue, 15 Aug 2023 08:51:38 +0000 (UTC) X-FDA: 81125720676.30.8CB3BEA Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) by imf21.hostedemail.com (Postfix) with ESMTP id 041191C000A for ; Tue, 15 Aug 2023 08:51:34 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b=jILeAcT8; dmarc=pass (policy=none) header.from=linaro.org; spf=pass (imf21.hostedemail.com: domain of linus.walleij@linaro.org designates 209.85.222.174 as permitted sender) smtp.mailfrom=linus.walleij@linaro.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692089496; a=rsa-sha256; cv=none; b=SP+cQIsEVF/h0SNVIdu3kMHgGxGLyWjwBvtAtyyl0P106pqs0z+BNFUWgA/qJJo3cizinj 9HOldqq3gGn16AnWdBNNXYCs/utidQz6XIJhWmlBJM2vSputZ46ydMl/QUQdDr/SXSWubv RIMEXeuD9C8+y+kFTbaD073PuhsyGIQ= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b=jILeAcT8; dmarc=pass (policy=none) header.from=linaro.org; spf=pass (imf21.hostedemail.com: domain of linus.walleij@linaro.org designates 209.85.222.174 as permitted sender) smtp.mailfrom=linus.walleij@linaro.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692089496; 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=Z+coH+wpo6G1L3l1018KvkQFkkscoUmA9S4G4+U1liU=; b=KrSvTaedfkuaS5v8sKoJucp+XXhQSIbFuJ8G4uU+dbluN/+G7foWk2YU7BLOD0Bq61cOdQ LmtHa1T76WUg5Yemfet7ernX+O0/ZLIXAgmE9nY+bool7kjInHTs7uFhaOiGkS1bZG0Y9B ANASK8cvwV9Anj9SrC9FSMsTdyS/8eM= Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-76571dae5feso351277185a.1 for ; Tue, 15 Aug 2023 01:51:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692089495; x=1692694295; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Z+coH+wpo6G1L3l1018KvkQFkkscoUmA9S4G4+U1liU=; b=jILeAcT8F/ZjGUdCFDoqyCtIzNFR4fZCkJfWZolfBjmDI9bsSwBAoFtDuPApcyHwj9 uOfZlWquq423IT7P9r5L2h6e/NI2BkhCg6puek3BOqaFF1IQmDUCTnQvXpZMfpkZ99pv X+FFE5S78IyXIE5RBSNAsuFh32j5KE0r2DfJ4kGqov5usQLMRPL5qBvcuI7GY2f8sqSf u+bFd9TYSxITCA9p6WGIP0Uvgym9xMJHr05U4bBWLCbCWMZ6DILTxgd3bf4ZqAsxxTJe zbf6QemG6K8EOJl6IfJ5Lz/IBMGE5M3OUs6xVMPPyIFhz1np7bPxZmW6IuNSsJvxE7nV DQdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692089495; x=1692694295; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z+coH+wpo6G1L3l1018KvkQFkkscoUmA9S4G4+U1liU=; b=JgvKl3ZvBVm+vlyPgO1RxdqR2JAms9fiGJcSoJV7fEphlNkx+YJIwjYmI/4XD5z+dK f7RhTaycwTrN+IGOEUUiChjRKPUV0ZmI+9u8xuDzTWTphvT+0c1wCy8UcNnqYfTFU6qu CFRJjOj7svioRpQwwC/wLhPyDOKmeBVgT3xrICe9wzg4rym9M2ihf+4DvlQDl5YeT9mk WObC4RWAGJWDSvc69xVdLcNdG0m3P3f32IF7TbQSD1ti2kSRP7zi2aD+8ufw2lZ1j86f ipeKsWQZAZiquDFtQ9RLHz9sRm57psD0wcs9gs3mld1pwhNsWyugzICVn6x8PdT5Vsf9 OnmA== X-Gm-Message-State: AOJu0Yws8uCHBYq30yGSxhMwKvA8Dvdy+XibrSrPsTYupYbIsnffIDWp mf71tnGw7VNQAabctcrApcR+eVIZv+sSXofFHWyISA== X-Google-Smtp-Source: AGHT+IGJOuWTMZv1UV4dsXeO6kHmmRY773XBZqzKSZ9eHc4ibHw4V17klynujZBGolKHTNLjULDkWQaZap43tGUDG/I= X-Received: by 2002:a05:620a:2452:b0:767:3b7d:687c with SMTP id h18-20020a05620a245200b007673b7d687cmr15500893qkn.15.1692089495607; Tue, 15 Aug 2023 01:51:35 -0700 (PDT) MIME-Version: 1.0 References: <20230813182552.31792-1-fmdefrancesco@gmail.com> In-Reply-To: <20230813182552.31792-1-fmdefrancesco@gmail.com> From: Linus Walleij Date: Tue, 15 Aug 2023 10:51:24 +0200 Message-ID: Subject: Re: [PATCH v2] Documentation/page_tables: Add info about MMU/TLB and Page Faults To: "Fabio M. De Francesco" Cc: Jonathan Corbet , Jonathan Cameron , Mike Rapoport , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Ira Weiny , Matthew Wilcox , Randy Dunlap Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 041191C000A X-Stat-Signature: 5ruaitdj1kztatkpamefqprw98dhij8f X-HE-Tag: 1692089494-503114 X-HE-Meta: U2FsdGVkX18aYbVC+gF8q5p1d5ZKy2tVtIOiIbzn94O0u3wOkhn4OGiwBFW1p1qyUDN4ss2TJYb+ZPeFDdHzjOdowDzxp+CMrQemmatn6a7vK6nmfte8fRjYvyC9FRR9E/2wxaw+tQl9+4lKoQ0CmObWp/YuwwfmluY/aIk/woxJaJm/tT4xs52KWBQV1bZ3hN1fhJLIbD1T1qk/yBk1xEak0Y8IpZCNqTegTzJF0ZV/oc3fIqGFo7J04R1cbd0Qykj9RwHuo5yXvokgKTjYk4DA0RA5ohEhhnpRXb/CNhu3hODwJtu5kwzYWxlPLnq9IlJk7s6MbZaEGEv5gHnjr7IUpfqfBhLKHzNtR1v68KUCcvvDcc6cPsIwlWRjbl1z9JkTrEAFn86buNK9xuOCSfSjVsRVuSJvhWiwrz7q8N/KSLjLlWq1PePdWacW1xTYDo7Z4grmsNNl957MRGFM/iwJOc6VZMKyeu5IO7eVidO9Ffd/n2VjGlKm7JhTyXTOQOfkUg7sMLrfHPF8+LyrFJiUjLIsROG/1ovftqRuHryOFjRb/myBZAD3iNvOXVneKc4JVutAAFAXL9ka2fn8HOehPY+XlRxO8iijJw5UliB0FgUIC62R84JkFRNeSHzN6D4EKErY5V0dM36GwYkEfJmX2BLnp0K4jdbW+cgTNAgenNrtIGr1meVwqz5pPVfawtHbGhRqQWw8SbX595UuxGmKIWX4oMOD16cNY+LRrZ40vc/kNC+nqnrj3t1+8dnhneMDTMgcKh7tCO0/mYmJVZQ1fTy+bjSttlFGi22GTbV4AmYnnbjxo4nUapEpJNzUubmg8YW6MYljMeaNmUuuhyawNBoULNJBfzvNO/U09zcNGB+QSjAKhzv4ZfSjkkX6KpZqkWnknD1rOhKwtoMJa7lZEYGe/IBhUqP/OvwVXVkq5sFuH7qZVl1KhM83P3/XBjlb5nEEgtFVcoXPM12 7l8hZHrw Y+DssAO7jcJEIscEIREfiig4B8oXt2Gvj3wYiP7lQ5eX6swqxCZXdi6MkI8GiKh5urPMyzS5sxgYrBV8S2NjjfwY+fzas91/mPUE6PrKopU0u4ViOqWFCPupZDLipVfsUORTuvt77jOOnkYwWjuGBJ61EgCZPge8Qru/pIY3L8R40+gq5cR+8jEjcsiShJqULBtheY6upwfGOu9BVyIjzHlqfJwX/OQ/b1PdqGps6nnpQ8+p7rkrDrY4gJZ2aWEHq6lMioj0CE+fKRipCCQHaeBaudu29QZkjOAGW84uJuxyh2tDZhAXugupga0IlPT5OS1DLyAFGMny2LgP8WlVPVwDEQfWK0LFg8LTE88EKRs1HnClWV7oRaWkLnnn492R0lrQ4RQmesATZHf9vclgnWK81Y2lZPPbRACyUHLGzlbFgltID/WGptEAdmINYqM8qENCkKnOqumKSX3mZvULiKt6xsl+9pfrjJNNjKjDTV5faOrzgvmkSnKMKN7E11Nq3zlIJ08UhVbPybt5SR/acw/CaemsBUbMw0dbT5RUG7Vg2xS89rWWyG3wdKoQ+XPpzyYXHV2rCnbWVTNVyuksVPGeOFLgnYsMX5qCaO+mSi77Uyhb8aGAuiD96UvKq32H1XoWk X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi Fabio, overall this v2 looks good! The below are my grammar and spelling nitpicks. On Sun, Aug 13, 2023 at 8:25=E2=80=AFPM Fabio M. De Francesco wrote: > Extend page_tables.rst by adding a section about the role of MMU and TLB > in translating between virtual addresses and physical page frames. > Furthermore explain the concept behind Page Faults and how the Linux > kernel handles TLB misses. Finally briefly explain how and why to disable > the page faults handler. > > Cc: Andrew Morton > Cc: Ira Weiny > Cc: Jonathan Cameron > Cc: Jonathan Corbet > Cc: Linus Walleij > Cc: Matthew Wilcox > Cc: Mike Rapoport > Cc: Randy Dunlap > Signed-off-by: Fabio M. De Francesco (...) > +If the above-mentioned conditions happen in user-space, the kernel sends= a > +`Segmentation Fault` (SIGSEGV) signal to the current thread. That signal= usually > +causes the termination of the thread and of the process it belongs to. > + > +Instead, there are also common and expected other causes of page faults.= These The word you are looking for is "Additionally" right? "Additionally, there are..." > +These techniques improve memory efficiency, reduce latency, and minimize= space > +occupation. This document won't go deeper into the details of "Lazy Allo= cation" > +and "Copy-on-Write" because these subjects are out of scope for they bel= ong to "for they belong" -> "as they belong" (I think) > +Swapping differentiate itself from the other mentioned techniques becaus= e it's differentiates > +not so desirable since it's performed as a means to reduce memory under = heavy > +pressure. "not so desirable" -> "undesirable" > +Swapping can't work for memory mapped by kernel logical addresses. These= are a "kernel logical addresses" -> "kernel-internal logical addresses" > +If everything fails to make room for the data that must reside be presen= t in "If everything fails" -> "If the kernel fails" > +This document is going to simplify and show an high altitude view of how= the > +Linux kernel handles these page faults, creates tables and tables' entri= es, > +check if memory is present and, if not, requests to load data from persi= stent > +storage or from other devices, and updates the MMU and its caches... Skip "..." for just period "." > +The first steps are architectures dependent. Most architectures jump to architectures -> architecture > +Whatever the routes, all architectures end up to the invocation of > +`handle_mm_fault()` which, in turn, (likely) ends up calling > +`__handle_mm_fault()` to carry out the actual work of allocation of the = page > +tables. "of allocation of the" -> "of allocating the" > +`__handle_mm_fault()` carries out its work by calling several functions = to > +find the entry's offsets of the upper layers of the page tables and allo= cate > +the tables that it may need to. Skip the last "to". > +Linux supports larger page sizes than the usual 4KB (i.e., the so called > +`huge pages`). When using these kinds of larger pages, higher level page= s can > +directly map them, with no need to use lower level page entries (PTE). H= uge > +pages contain large contiguos physical regions that usually span from 2M= B to contiguous > +The huge pages bring with them several benefits like reduced TLB pressur= e, > +reduced page table overhead, memory allocation efficiency, and performan= ce > +improvement for certain workloads. However, these benefits come with > +trade-offs, like wasted memory and allocation challenges. Huge pages are= out > +of scope of the present document, therefore, it won't go into further de= tails. Since you explain what they are, it feels they are in scope? I would just skip the last sentence. > +To conclude this brief overview from very high altitude of how Linux han= dles To conclude this high altitude view of... > +Several code path make use of the latter two functions because they need= to code paths With or without the above suggestions: Reviewed-by: Linus Walleij Yours, Linus Walleij