logo资料库

深入理解linux内核架构英文版.pdf

第1页 / 共1370页
第2页 / 共1370页
第3页 / 共1370页
第4页 / 共1370页
第5页 / 共1370页
第6页 / 共1370页
第7页 / 共1370页
第8页 / 共1370页
资料共1370页,剩余部分请下载后查看
Professional Linux Kernel Architecture
About the Author
Credits
Acknowledgments
Contents
Introduction
What This Book Covers
Chapter 1: Introduction and Overview
1.1 Tasks of the Kernel
1.2 Implementation Strategies
1.3 Elements of the Kernel
1.4 Why the Kernel Is Special
1.5 Some Notes on Presentation
1.6 Summary
Chapter 2: Process Management and Scheduling
2.1 Process Priorities
2.2 Process Life Cycle
2.3 Process Representation
2.4 Process Management System Calls
2.5 Implementation of the Scheduler
2.6 The Completely Fair Scheduling Class
2.7 The Real-Time Scheduling Class
2.8 Scheduler Enhancements
2.9 Summary
Chapter 3: Memory Management
3.1 Overview
3.2 Organization in the (N)UMA Model
3.3 Page Tables
3.4 Initialization of Memory Management
3.5 Management of Physical Memory
3.6 The Slab Allocator
3.7 Processor Cache and TLB Control
3.8 Summary
Chapter 4: Virtual Process Memory
4.1 Introduction
4.2 Virtual Process Address Space
4.3 Principle of Memory Mappings
4.4 Data Structures
4.5 Operations on Regions
4.6 Address Spaces
4.7 Memory Mappings
4.8 Reverse Mapping
4.9 Managing the Heap
4.10 Handling of Page Faults
4.11 Correction of Userspace Page Faults
4.12 Kernel Page Faults
4.13 Copying Data between Kernel and Userspace
4.14 Summary
Chapter 5: Locking and Interprocess Communication
5.1 Control Mechanisms
5.2 Kernel Locking Mechanisms
5.3 System V Interprocess Communication
5.4 Other IPC Mechanisms
5.5 Summary
Chapter 6: Device Drivers
6.1 I/O Architecture
6.2 Access to Devices
6.3 Association with the Filesystem
6.4 Character Device Operations
6.5 Block Device Operations
6.6 Resource Reservation
6.7 Bus Systems
6.8 Summary
Chapter 7: Modules
7.1 Overview
7.2 Using Modules
7.3 Inserting and Deleting Modules
7.4 Automation and Hotplugging
7.5 Version Control
7.6 Summary
Chapter 8: The Virtual Filesystem
8.1 Filesystem Types
8.2 The Common File Model
8.3 Structure of the VFS
8.4 Working with VFS Objects
8.5 Standard Functions
8.6 Summary
Chapter 9: The Extended Filesystem Family
9.1 Introduction
9.2 Second Extended Filesystem
9.3 Third Extended Filesystem
9.4 Summary
Chapter 10: Filesystems without Persistent Storage
10.1 The proc Filesystem
10.2 Simple Filesystems
10.3 Sysfs
10.4 Summary
Chapter 11: Extended Attributes and Access Control Lists
11.1 Extended Attributes
11.2 Access Control Lists
11.3 Summary
Chapter 12: Networks
12.1 Linked Computers
12.2 ISO/OSI and TCP/IP Reference Model
12.3 Communication via Sockets
12.4 The Layer Model of Network Implementation
12.5 Networking Namespaces
12.6 Socket Buffers
12.7 Network Access Layer
12.8 Network Layer
12.9 Transport Layer
12.10 Application Layer
12.11 Networking from within the Kernel
12.12 Summary
Chapter 13: System Calls
13.1 Basics of System Programming
13.2 Available System Calls
13.3 Implementation of System Calls
13.4 Summary
Chapter 14: Kernel Activities
14.1 Interrupts
14.2 Software Interrupts
14.3 Tasklets
14.4 Wait Queues and Completions
14.5 Summary
Chapter 15: Time Management
15.1 Overview
15.2 Implementation of Low-Resolution Timers
15.3 Generic Time Subsystem
15.4 High-Resolution Timers
15.5 Dynamic Ticks
15.6 Broadcast Mode
15.7 Implementing Timer-Related System Calls
15.8 Managing Process Times
15.9 Summary
Chapter 16: Page and Buffer Cache
16.1 Structure of the Page Cache
16.2 Structure of the Buffer Cache
16.3 Address Spaces
16.4 Implementation of the Page Cache
16.5 Implementation of the Buffer Cache
16.6 Summary
Chapter 17: Data Synchronization
17.1 Overview
17.2 The pdflush Mechanism
17.3 Starting a New Thread
17.4 Thread Initialization
17.5 Performing Actual Work
17.6 Periodic Flushing
17.7 Associated Data Structures
17.8 Central Control
17.9 Superblock Synchronization
17.10 Inode Synchronization
17.11 Congestion
17.12 Forced Writeback
17.13 Laptop Mode
17.14 System Calls for Synchronization Control
17.15 Full Synchronization
17.16 Summary
Chapter 18: Page Reclaim and Swapping
18.1 Overview
18.2 Page Reclaim and Swapping in the Linux Kernel
18.3 Managing Swap Areas
18.4 The Swap Cache
18.5 Writing Data Back
18.6 Page Reclaim
18.7 The Swap Token
18.8 Handling Swap-Page Faults
18.9 Initiating Memory Reclaim
18.10 Shrinking Other Caches
18.11 Summary
Chapter 19: Auditing
19.1 Overview
19.2 Audit Rules
19.3 Implementation
19.4 Summary
Appendix A: Architecture Specifics
A.1 Overview
A.2 Data Types
A.3 Alignment
A.4 Memory Pages
A.5 System Calls
A.6 String Processing
A.7 Thread Representation
A.8 Bit Operations and Endianness
A.9 Page Tables
A.10 Miscellaneous
A.11 Summary
Appendix B: Working with the Source Code
B.1 Organization of the Kernel Sources
B.2 Configuration with Kconfig
B.3 Compiling the Kernel with Kbuild
B.4 Useful Tools
B.5 Debugging and Analyzing the Kernel
B.6 User-Mode Linux
B.7 Summary
Appendix C: Notes on C
C.1 How the GNU C Compiler Works
C.2 Standard Data Structures and Techniques of the Kernel
C.3 Summary
Appendix D: System Startup
D.1 Architecture-Specific Setup on IA-32 Systems
D.2 High-Level Initialization
D.3 Summary
Appendix E: The ELF Binary Format
E.1 Layout and Structure
E.2 Data Structures in the Kernel
E.3 Summary
Appendix F: The Kernel Development Process
F.1 Introduction
F.2 Kernel Trees and the Structure of Development
F.3 The Structure of Patches
F.4 Linux and Academia
F.5 Summary
References
Index
Mauerer ffirs.tex V2 - 08/26/2008 3:23am Page iii Professional Linux® Kernel Architecture Wolfgang Mauerer Wiley Publishing, Inc.
Mauerer ffirs.tex V2 - 08/26/2008 3:23am Page ii
Mauerer ffirs.tex V2 - 08/26/2008 3:23am Page i Professional Linux® Kernel Architecture Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii Chapter 1: Introduction and Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Chapter 2: Process Management and Scheduling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Chapter 3: Memory Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 Chapter 4: Virtual Process Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 Chapter 5: Locking and Interprocess Communication . . . . . . . . . . . . . . . . . . . . . . . 347 Chapter 6: Device Drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391 Chapter 7: Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473 Chapter 8: The Virtual Filesystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519 Chapter 9: The Extended Filesystem Family . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583 Chapter 10: Filesystems without Persistent Storage . . . . . . . . . . . . . . . . . . . . . . . 643 Chapter 11: Extended Attributes and Access Control Lists . . . . . . . . . . . . . . . . . 707 Chapter 12: Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733 Chapter 13: System Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 819 Chapter 14: Kernel Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 847 Chapter 15: Time management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 893 Chapter 16: Page and Buffer Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 949 Chapter 17: Data Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 989 Chapter 18: Page Reclaim and Swapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1023 Chapter 19: Auditing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1097 Appendix A: Architecture Specifics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1117 Appendix B: Working with the Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1141 Appendix C: Notes on C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1175 Appendix D: System Startup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1223 Appendix E: The ELF Binary Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1241 Appendix F: The Kernel Development Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1267 Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1289 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1293
Mauerer ffirs.tex V2 - 08/26/2008 3:23am Page ii
Mauerer ffirs.tex V2 - 08/26/2008 3:23am Page iii Professional Linux® Kernel Architecture Wolfgang Mauerer Wiley Publishing, Inc.
Mauerer ffirs.tex V2 - 08/26/2008 3:23am Page iv Professional Linux® Kernel Architecture Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2008 by Wolfgang Mauerer Published by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-0-470-34343-2 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 Library of Congress Cataloging-in-Publication Data: Mauerer, Wolfgang, 1978- Professional Linux kernel architecture / Wolfgang Mauerer. p. cm. Includes index. ISBN 978-0-470-34343-2 (pbk.) 1. Linux. 2. Computer architecture. 3. Application software. QA76.9.A73M38 2008 005.4’32--dc22 I. Title. 2008028067 No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online at http://www.wiley.com/go/permissions. Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Website is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Website may provide or recommendations it may make. Further, readers should be aware that Internet Websites listed in this work may have changed or disappeared between when this work was written and when it is read. For general information on our other products and services please contact our Customer Care Department within the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002. Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.
Mauerer fauth.tex V2 - 08/22/2008 4:52am Page v About the Author Wolfgang Mauerer is a quantum physicist whose professional interests are centered around quantum cryptography, quantum electrodynamics, and compilers for — you guessed it — quantum architectures. With the confirmed capacity of being the worst experimentalist in the known universe, he sticks to the theoretical side of his profession, which is especially reassuring considering his constant fear of acci- dentally destroying the universe. Outside his research work, he is fascinated by operating systems, and for more than a decade — starting with an article series about the kernel in 1997 — he has found great pleasure in documenting and explaining Linux kernel internals. He is also the author of a book about typesetting with LaTeX and has written numerous articles that have been translated into seven languages in total. When he’s not submerged in vast Hilbert spaces or large quantities of source code, he tries to take the opposite direction, namely, upward — be this with model planes, a paraglider, or on foot with an ice axe in his hands: Mountains especially have the power to outrival even the Linux kernel. Consequently, he considers planning and accomplishing a first-ascent expedition to the vast arctic glaciers of east Green- land to be the really unique achievement in his life. Being interested in everything that is fundamental, he is also the author of the first compiler for Plankalk ¨ul, the world’s earliest high-level language devised in 1942–1946 by Konrad Zuse, the father of the computer. As an avid reader, he is proud that despite the two-digit number of computers present in his living room, the volume required for books still occupies a larger share.
Mauerer fauth.tex V2 - 08/22/2008 4:52am Page vi
分享到:
收藏